Prerequisites
You have connected your project to mPaaS. For more information, see the following topics:
Add the SDK
Choose the method that matches your connection type.
Use the mPaaS Xcode Extension. This method applies if you connected your project using the mPaaS framework or the mPaaS plugin.
In the Xcode menu, click Editor > mPaaS > Edit Project to open the project editing page.
Select Ariver Mini Program, save the settings, and then click Start Editing to add the component.
Use the cocoapods-mPaaS plugin. This method applies if you connected your project using CocoaPods.
In the Podfile, set the baseline version to
10.2.3and add the Ariver mini program component dependency usingmPaaS_pod "mPaaS_Ariver".
Run the
pod mpaas update 10.2.3command to update the baseline.In the command line, run
pod installto complete the connection.
The following sections use the official mini program demo to demonstrate how to use mini programs. The process has three main steps:
Initialize configurations
Initialize the mPaaS framework
If the app lifecycle is handled by your custom delegate instead of the mPaaS framework (as shown in the following figure), you must initialize the mPaaS framework manually.
If the app lifecycle is managed by the mPaaS framework, the app delegate is set to `DFClientDelegate`. In this case, you do not need to initialize the mPaaS framework manually.

After the app's
windowandnavigationControllerare created, call the following method to initialize the mPaaS framework.
In the
categoryofDTFrameworkInterface, override theshouldInheritDFNavigationControllermethod and returnNO. This prevents the navigation controller from inheriting fromDFNavigationController.
If the app has multiple navigation bars and you need to open different mini programs in them, reset the container's navigation bar after you switch navigation bars.

Initialize the container
To ensure the mini program starts correctly, you must call the SDK interface to initialize the container after the app starts. This initialization must be performed in the - (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions method of DTFrameworkInterface.
- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initialize the container
[MPNebulaAdapterInterface initNebula];
}Notes
In baseline 10.2.3, this note applies if you use the managed mode of the mPaaS framework, use the privacy pop-up, and set the switch configuration delegate using [MPNebulaAdapterInterface shareInstance].configDelegate = self;. If these conditions apply, you must set the switch delegate in both of the following methods. If you do not use a switch delegate, you can ignore this section.


Publish the mini program
Before you can start a mini program, you must publish it from the mPaaS console.
Log on to the mPaaS console and go to your target application. In the navigation pane on the left, choose Mini Program > Mini Program Release.
Configure a virtual domain name. If you are configuring a virtual domain name for the first time, go to Mini Program > Mini Program Release > Configuration Management. The virtual domain name must be under your company's domain name, such as
example.com, to prevent hijacking by third parties.Create a mini program. In the mPaaS console, follow these steps:
In the navigation pane on the left, choose Mini Program > Mini Program Release.
On the mini program package list page, click Create.
In the Create Mini Program window, enter the mini program ID and name, and then click OK. The mini program ID must be a 16-digit number, such as
2018080616290001.In the mini program app list, find the new mini program and click Add.
In the Basic Information section, complete the following configurations:
Version: Enter the version number of the mini program package, such as
1.0.0.0.Client Scope: Select the minimum and maximum iOS client versions for the mini program app. Only client apps with versions within this range can start the mini program. You can set the minimum version to
0.0.0and leave the maximum version empty. This configuration allows all client versions to start this mini program.NoteThis version number refers to the value of the
Product Versionfield in the project'sInfo.plistfile.
Icon: Click Select File to upload an icon for the mini program package. You must upload an icon when you create a mini program for the first time. The following figure shows a sample icon:

Upload the mini program package resource file. The file format is
.zip. An mPaaS sample mini program (download here) is available for you to upload directly.NoteBefore you upload, change the
.zipfilename of this sample mini program and the folder name inside the ZIP file to the 16-digit ID of your mini program.
In the Configuration Information section, complete the following configurations:
Main Entry URL: Required. This is the home page of the mini program. The format is
/index.html#xxx/xxx/xxx/xxx. The part after#, which isxxx/xxx/xxx/xxx, must be the first value in thepagesarray of the mini program'sapp.jsonfile. For example, as shown in the following figure, the main entry for the mPaaS sample mini program is/index.html#page/tabBar/component/index.
Keep the default values for other configurations.
Select the I confirm that the above information is accurate and will not be modified after submission checkbox.
Click Submit.
Publish the mini program. In the mPaaS console, complete the following steps:
In the navigation pane on the left, choose Mini Program > Mini Program Release > Official Mini Program Package Management.
On the mini program package list page, select the package and version you want to publish, and then click Create Release.
In the Create Release taskbar, complete the following configurations:
Release Type: Select the Official release type.
Release Description: Optional.
Click OK to create the release.
Start the mini program
After you complete these steps, you can start the sample mini program in your iOS project using the following code:
[MPNebulaAdapterInterface startTinyAppWithId:@"2018080616290001" params:nil];The 2018080616290001 in the code is an example mini program ID. You must replace it with your own mini program ID.


