Prerequisites
You have connected the project to mPaaS. Related topics:
Add an SDK
Select an add method based on your integration method.
Use mPaaS Xcode Extension This method is applicable to mPaaS-based integration or existing projects that use mPaaS plug-ins.
Click the Xcode menu item Editor > mPaaS > Edit Project to open the Edit Project page.
Select Ariver mini program and click Edit.
Use cocoapods-mPaaS plug-ins This method is applicable to the integration mode that uses CocoaPods based on existing projects.
In the Podfile file, specify the baseline number as
cp_change_15200851and use themPaaS_pod "mPaaS_Ariver"to add the dependency of the Ariver mini program component.
Run the
pod mpaas update cp_change_15200851command to update the baseline.Run
pod installon the command line to complete the connection.
The following section describes how to use a mini program based on the official demo of the mini program. The whole process is divided into the following three steps:
Initialize the SDK
Initialize the mPaaS framework
If the lifecycle of the app is not managed by the mPaaS framework, but is specified as a delegate defined by yourself, as shown in the following figure, you must manually initialize the mPaaS framework.
mPaaS framework hosting means that the app's delegate is set to DFClientDelegate. In this case, you do not need to manually initialize the mPaaS framework.

After the
windowandnavigationControllerof the application are created, call the following method to initialize the mPaaS framework.
Overriding the
shouldInheritDFNavigationControllermethod in aDTFrameworkInterfacecategoryand returning aNO, the support navigation bar controller may not inherit theDFNavigationController.
If an app has multiple navigation bars and you need to open different mini programs in different navigation bars, you must reset the navigation bar of the container after you switch the navigation bar.

Init Containers
To correctly start the mini program, you need to call the SDK interface to initialize the container after the app is started. Must be initialized in a DTFrameworkInterface- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions.
- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initialize the container.
[MPNebulaAdapterInterface initNebula];
}Precautions
In the cp_change_15200851 baseline, if the hosting mode and privacy pop-up box of the mPaaS framework is used and the switch configuration agent [MPNebulaAdapterInterface shareInstance].configDelegate = self; is set, you need to set the switch proxy in the following two methods at the same time; if the switch configuration agent is not set, please ignore it.


Release mini program
Before starting the mini program, you need to release the mini program in the mPaaS console. The steps are as follows:
Enter the background of the mini program. Log on to the mPaaS console. In the left-side navigation pane, choose Mini Program > Release.
Configure the virtual domain name. If this is the first time you configure a virtual domain name, you must first configure a virtual domain name in the Mini Program > Mini Program Release > Configuration Management. The virtual domain name must be hung under the enterprise domain name to prevent it from being hijacked by third parties, such as
example.com.Create a mini program. Go to the mPaaS console and perform the following operations:
In the left-side navigation pane, choose Mini Program > Mini Program Release.
On the page that appears, click Create.
In the Create Mini Program dialog box, enter the ID and name of the mini program and click OK. The mini program ID is any 16-bit number, for example,
2018080616290001.In the mini app list, find the new mini app and click Add.
In the Basic Information section, configure the following information:
Version: Enter the version number of the small package, for example,
1.0.0.0.Client Range: Select the minimum and maximum versions of the iOS client corresponding to the mini program app. The client App within this range can start the corresponding small program, otherwise it cannot be started. Here, the minimum version can be filled in
0.0.0, and the maximum version can be left unfilled, which means that all versions of the client can start this mini program.NoteThe version number here refers to the version number of the current client app. For more information, see the
Product Versionfield in the projectInfo.plist.
Icon: Click the Select File icon to upload the small package. You must upload the icon when you create the mini program for the first time. An example icon is as follows:

Upload the small package resource file in the
.zipformat. We have prepared a small mPaaS sample program (click here to download ), which can be uploaded directly.NoteBefore you upload the mini program, you must change the
.zipfile name and folder name in the package to the 16-digit ID of the mini program.
In the configuration information bar, complete the following configurations:
Main Portal URL: required. The homepage of the mini program. The format of the main entry URL is:
/index.html#xxx/xxx/xxx/xxx, where thexxx/xxx/xxx/xxxafter#is the first value in thepagesin theapp.jsonof the mini program. The main entry point of the mPaaS mini program is:/index.html#page/tabBar/component/index.Keep the default settings for other configurations.
Select the Confirm that the preceding information is accurate and do not modify it after you submit it check box.
Click Submit.
Release the mini program. Go to the mPaaS console and complete the following steps:
In the left-side navigation pane, choose Mini Program > Mini Program Release > Official Mini Program Package Management.
On the Small Packages page, select the small package and version that you want to release, and click Create Release.
In the Create Release panel, configure the following settings:
Release Type: Select Official.
Release Description: Optional.
Click OK to create the release.
Start mini program
After you complete the preceding steps, run the following code to start the sample mini program in the iOS project:
[MPNebulaAdapterInterface startTinyAppWithId:@"2018080616290001" params:nil];The 2018080616290001 in the above code is the ID of the mini program. This is only an example in this article. Enter the ID of your mini program.