Preview and debug iOS Mini Programs on real devices

Updated at:

This topic describes how to preview and debug Mini Programs on a real iOS device.

Note

Previewing and debugging Mini Programs on real devices is supported only in mPaaS 10.1.60 and later.

Follow these steps to enable the preview and debug feature:
  1. Obtain the QR code content string from the QR code in the IDE, such as by scanning the code.

  2. Call the Mini Program preview and debug API.

    • Pass the QR code content string:

      [MPNebulaAdapterInterface startDebugTinyAppWithUrl:qrCode];
    • Or, call the API with custom parameters:

      [MPNebulaAdapterInterface startDebugTinyAppWithUrl:qrCode params:nil];

      To pass parameters when you open the Mini Program, use the param parameter. The param parameter contains two fields: page and query:

      • page: Specifies the path to a specific page to open.

      • query: Passes custom parameters. Multiple key-value pairs are concatenated with &.

        NSDictionary *param = @{@"page":@"pages/card/index", @"query":@"own=1&sign=1&code=2452473"};
        [MPNebulaAdapterInterface startTinyAppWithId:appId params:dic];

Configure the whitelist

When you use the real-device preview and debug feature, you must configure a unique user identity in the category of MPaaSInterface. In the `userId` method, return a unique identifier for the application, such as a username, phone number, or mailbox. The value that you enter in the Configure Whitelist section of the Mini Program IDE plugin must match this `userId`.

#import <mPaas/MPaaSInterface.h>
@implementation MPaaSInterface (MPTinyAppDemo_pod)

- (NSString *)userId
{
    return @"mPaaS";
}

@end