All Products
Search
Document Center

Mobile Platform as a Service:Getting started

Last Updated:Aug 29, 2023

Update the SDK

You can use the Cocoapods plug-in to update the SDK.

  1. Run the following command in Cocoapods to update to a custom baseline:

    pod mpaas update cp_change_31395
  2. Run the following command to install the SDK:

    pod update

Initialize an API operation

Automatic hosting

Initialize without parameters

[MPNebulaAdapterInterface initNebula];

Initialize with Parameters

// Initialize the mini program and customize parameters.
NSString *presetApplistPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"MPCustomPresetApps.bundle/h5_json.json"] ofType:nil];
NSString *appPackagePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"MPCustomPresetApps.bundle"] ofType:nil];
NSString *pluginsJsapisPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Poseidon-UserDefine-Extra-Config.plist"] ofType:nil];
[MPNebulaAdapterInterface initNebulaWithCustomPresetApplistPath:presetApplistPath customPresetAppPackagePath:appPackagePath customPluginsJsapisPath:pluginsJsapisPath];

Manual hosting

/**
 * Start the mPaaS framework when it is not hosted by the mPaaS framework.
 * The non-mPaaS framework-managed integration means that the delegate in the main method is a custom delegate. This method must be called after the application is started and the navigationcontroller is initialized.
 *
 * @param application The current application.
 * @param launchOptions The startup parameters of the current application.
 * @param window The keywindow of the current application. Cannot be empty
 * @param navigationController the navigation stack where the offline package or mini program page is located in the current application. The value cannot be empty. Otherwise, the offline package or mini program cannot be opened.
 */
- (void)manualInitMpaasFrameworkWithApplication:(UIApplication *)application launchOptions:(NSDictionary *)launchOptions window:(UIWindow * __nonnull)window navigationController:(UINavigationController * __nonnull)navigationController;
// The keywindow of the current application. Cannot be empty
// This value will be set according to the passed-in parameters when calling the above initialization method, only for internal method calls, please do not repeat set
@property (nonatomic, strong) UIWindow *__nonnull mPaaSFrameworkWindow;
// In the current application, you need to open the navigation stack where the offline package or mini program page is located. The value cannot be empty. Otherwise, the offline package or mini program cannot be opened.
// This value will be set according to the passed-in parameters when calling the above initialization method, only for internal method calls, please do not repeat set
@property (nonatomic, strong) UINavigationController *__nonnull mPaaSFrameworkNavigationController;

Startup and Configuration

//MPNebulaAdapterInterface

/**
 Initialize the Nebula container
-must be initialized in the DTFrameworkInterface- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions or earlier timing such as +(void)load
 */
+ (void)initNebula;

/**
 Initialize the Nebula container
 -must be initialized in the DTFrameworkInterface- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions or earlier timing such as +(void)load
 
 @ param customPresetApplistPath the path of the preset offline package information file. For example, [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"MPCustomPresetApps.bundle/NebulaApplist.plist"] ofType:nil]
 @ param customPresetAppPackagePath the package path of the custom preset offline package, such as [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"MPCustomPresetApps.bundle"] ofType:nil]
 @ param customPluginsJsapisPath the path of the custom plugins and jsapis information files, such as [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Poseidon-UserDefine-Extra-Config.plist"] ofType:nil]
 **/
+ (void)initNebulaWithCustomPresetApplistPath:(NSString *)customPresetApplistPath customPresetAppPackagePath:(NSString *)customPresetAppPackagePath customPluginsJsapisPath:(NSString *)customPluginsJsapisPath;

/**
 The VC base class of the H5 page created based on the Nebula container. Default value: H5 WebViewController. If you need to customize the VC where the H5 page is located, you can set this attribute after customizing the VC.
 Note: The custom base class must inherit the 'H5WebViewController
 */
@property (nonatomic, strong) Class nebulaVeiwControllerClass;

/**
 The webview base class that is embedded in the H5 page created based on the Nebula container. Default value: WKWebView. If you need to customize the webview of the H5 page, you can set this property after customizing the webview.
 */
@property (nonatomic, strong) Class nebulaWebViewClass;

/**
 Specifies whether to use WKWebView to load offline package pages. The default value is YES.
 */
@property (nonatomic, assign) BOOL nebulaUseWKArbitrary;

/**
 Set the UserAgent of the current application to all H5 pages created based on the Nebula container.
 */
@property (nonatomic, strong) NSString *nebulaUserAgent;

/**
Whether the offline package is verified. The default value is YES, that is, the Nebula container verifies the signature of the downloaded offline package by default. If you need to disable signature verification during debugging, set this property to NO
 */
@property (nonatomic, assign) BOOL nebulaNeedVerify;

/**
 The path of the public key for offline package signature verification. Default value: nil. If the offline package signature verification switch is set to YES, you must set the corresponding public key here. Otherwise, the offline package fails to be loaded if the local signature verification fails.
 */
@property (nonatomic, strong) NSString *nebulaPublicKeyPath;

/**
 Global resource package list
 */
@property (nonatomic, strong) NSArray *nebulaCommonResourceAppList;

/**
 The path of the HTML error page that is displayed when the H5 page fails to load. By default, the MPNebulaAdapter is read. bundle/error.html
 */
@property (nonatomic, strong) NSString *errorHtmlPath;

/**
 Open a new link and adopt a new interception method for 11.3 and above systems.
 */
@property (nonatomic, assign) BOOL nebulaUseNewInterceptLink;

/**
 Set the custom switch delegate, gray function range custom switch, switch priority is APConfig > here custom switch> default built-in switch
 */
@property(nonatomic, weak) id<MPNebulaAdapterInterfaceConfigProtocol> configDelegate;

/**
 Specifies the update frequency of global offline package requests. Default value: 1800. Unit: seconds. Maximum value: 24 hours.
*/
@property(nonatomic, assign) NSTimeInterval nebulaUpdateReqRate;

/**
 Custom package downloader. Note that you must implement the @ selector(download:params:process:finish :) method
*/
@property (nonatomic, strong) id<NXRDownloadProtocol> customDownloadManager;

/**
 Custom package downloader. Note that you must implement the @ selector(requestApps:params:finish :) method
*/
@property (nonatomic, strong) id<MPCustomExtendInfo> customRequestManager;

/**
 * Create an H5 container based on the online URL and automatically push the container to open it.
 *
 * @param params H5 the startup parameters of the container. Required parameter: url. For other optional parameters, see Documentation https://tech.antfin.com/docs/2/85001.
 *
 */
- (void)startH5ViewControllerWithParams:(NSDictionary *)params;

/**
 * Create an H5 container based on the incoming offline package information and automatically push it to open it.
 *
 * @param params H5 the startup parameter of the container. Required parameter: appId. For other optional parameters, see Documentation https://tech.antfin.com/docs/2/85001.
 *
 */
- (void)startH5ViewControllerWithNebulaApp:(NSDictionary *)params;

/**
 * Create an H5 container based on the passed URL information and return the created H5 container instance. Generally used in the home tab page
 *
 * @param params H5 the startup parameters of the container. Required parameter: url. For other optional parameters, see Documentation https://tech.antfin.com/docs/2/85001.
 *
 * @return The H5 container VC instance created.
 */
- (UIViewController *)createH5ViewController:(NSDictionary *)params;

/**
 * Create an H5 container based on the incoming offline package information and return the created H5 container instance. Generally used in the home tab page
 *
 * @param params H5 the startup parameter of the container. Required parameter: appId. For other optional parameters, see Documentation https://tech.antfin.com/docs/2/85001.
 *
 * @return The H5 container VC instance created.
 */
- (UIViewController *)createH5ViewControllerWithNebulaApp:(NSDictionary *)params;

/**
 Open mini program package
 
 @ param appId The ID of the mini program.
 @ param params The parameters of the mini program.
 */
+ (void)startTinyAppWithId:(NSString*)appId params:(NSDictionary*)params;

/**
Open mini program package

@ param appId The ID of the mini program.
@ param params The parameters of the mini program.
*
* @return The opening result of the mini-application. The result does not indicate whether the mini-application is successfully opened.
*/
+ (BOOL)startTinyAppGetReturnWithId:(NSString*)appId params:(NSDictionary*)params;

/**
 Scan mPaaS mini program IDE preview /debug QR code for preview and remote debugging
 
 @ param qrCode mPaaS mini program IDE preview /debug QR code string
 */
+ (void)startDebugTinyAppWithUrl:(NSString*)qrCode;


/**
Scan mPaaS mini program IDE preview /debug QR code for preview and remote debugging

@ param qrCode mPaaS mini program IDE preview /debug QR code string
@ param params mini program parameters cannot conflict with the key in the dictionary parsed from the two-dimensional code, otherwise the mini program parameters with the same key will be overwritten.
*/
+ (void)startDebugTinyAppWithUrl:(NSString*)qrCode params:(NSDictionary*)params;

/**
 * Full update of local offline package information
 *
 * @param finish The completion callback.
 *
 */
- (void)requestAllNebulaApps:(NAMRequestFinish)finish;

/**
 * Single application request
 *
 * Note:
 * Before 9.9.9: After the request is successful, offline packages are automatically downloaded under Wifi. For non-Wifi, only offline packages with auto_install set to YES are downloaded.
 * 9.9.9 and later: download timing can be configured for each application, through server configuration, default WIFI download
 *
 * @param params The format of the request list:{appid:version}. You can specify multiple appIDs. If no version is specified, this parameter is empty. By default, the highest version is used.
 * Version number fuzzy match is supported for e.g. '*' matches the highest version number '1.*' matches the version number starting with 1 and the highest version number. The maximum length is 4 characters.
 * @param finish The completion callback.
 */
- (void)requestNebulaAppsWithParams:(NSDictionary *)params finish:(NAMRequestFinish)finish;


/**
 * Full download of offline packages in the package information pool
 *
 *
 */
- (void)downLoadAllNebulaApps;

/**
 * Download specified offline packages in batches
 *
 * @param params Dictionary {appId:version}, which specifies the ID and version number of the app to be downloaded. Read and download the app from the package management pool.
 */
- (void)downLoadNebulaAppsWithParams:(NSDictionary *)params;

/**
 * Install offline packages
 *
 * @param app The information about the offline package. You can use findApp: to find the package.
 * @param process The callback that is fired during the installation process. The process includes: Download the offline package asynchronously-> Decompress the offline package.
 * @param finish The callback that is fired when the installation is complete.
 */
- (void)installNebulaApp:(NAMApp *)app
                 process:(NAMAppInstallProcess)process
                  finish:(NAMAppInstallFinish)finish;

/**
 * Query the appId list of all applications.
 *
 * @param array [appId,appId...]
 */
- (NSArray *)allAppIds;

/**
 * Obtain the package information of a specified application.
 *
 * @param appId The array of application IDs.
 * @return NSDictionary instances of all apps {appId:[NAMApp, ...], ...}
 */
- (NSDictionary *)allAppsForAppId:(NSArray *)arrAppId;

/**
 * Obtain the package information of an installed application.
 *
 * @param list Dictionary {appId:version}. The information about all installed packages is returned when nil is passed.
 */
- (NSDictionary *)installedApps:(NSDictionary *)list;

/**
 * @brief Deletes the information of a specified local application, including the package information, AMR, and installation directory.
 *
 * @param appId The application ID.
 *
 *  @return
 */
-(void)clearAllAppInfo:(NSString *)appId;


// Customize the path of the plugins and jsapis configuration files.
@property (nonatomic, strong, readonly) NSString *customPluginsJsapisPath;

/**
* When the privacy permission popup is enabled, manually initialize the container Context in the afterDidFinishLaunchingWithOptions method. Otherwise, the container fails to be loaded.
*
*/
+ (void)setNBContextWhenEnablePrivacyAuth;

Regenerate Wireless Bodyguard Image (V6)

The method of regenerating the picture of the wireless bodyguard is as follows:

mpaas inst sgimage -c
/Users/xxx/Desktop/aaa/MPaaS/Targets/aaa/meta.config -V 6 -t 1 -o
/Users/xxx/Desktop --app-secret sssssdderrff --verbose

Parameters introduction:

  • -c: The file path meta.config in the project.

  • -V: Fixed at 6.

  • -t: Fixed at 1.

  • -o: The output path of the yw_1222.jpg image.

  • -app-secret: The app-secrect of the current application.

Update the base class of a custom container

If the base class of the container is customized in the project, you need to change the inherited parent class from H5WebViewController to NXDefaultViewController after upgrading to a new mini program container.