How tencentcloud/tcmpp-demo-ios works
Main Components
• User Interface (UI) Layer: Represented by the AppDelegate, storyboards (LaunchScreen, Main), and various view controllers (e.g., TCMPPMainVC, TCMPPLoginVC, TCMPPMenuView, TCMPPPayView). This layer handles user interaction.
• Configuration Manager: In the AppDelegate you see the initialization of TMAServerConfig by loading a JSON configuration file (tcmpp-ios-configurations.json). This component provides the app with runtime configuration.
• Mini Program SDK Manager: The TMFMiniAppSDKManager (a shared instance) is responsible for bootstrapping the mini program engine, utilizing the configuration, and managing startup operations (including checking for updates or caching behavior).
• Custom API and Utilities: The “CustomApi” folder and “Utils” directory offer utility classes and custom APIs (e.g., PayRequestJsApi, StateEventTest) that extend or interact with the SDK.
• External Remote Server: Although not directly part of the codebase, the README explains that the mini program is first loaded from a local cache and then verified/updated by connecting to a remote server. This external service is a critical part of the overall system.
Out the Relationships and Interactions
• The UI layer (invoked via the AppDelegate during application launch) acts as the entry point.
• The Custom API and Utility modules act as supporting services for payment processing, language management, and event handling, aiding the UI or SDK integration components.
Architectural Patterns and Design Principles
• The design follows a separation of concerns – the UI is clearly separated from the business logic (configuration and SDK management) and support utilities.
• Use of singletons (for the shared instance of TMFMiniAppSDKManager) centralizes the mini program management.
• The application follows standard MVC patterns common in iOS development, with View Controllers (and storyboards) handling UI, while managers and utility classes manage data and external interactions.
Technologies and Frameworks
• iOS native frameworks (UIKit, Storyboards).
• CocoaPods is used for dependency management, as seen in the Podfile instructions.
• The project leverages configuration management via JSON and uses a custom SDK (TCMPPSDK) for mini program integration.