All Products
Search
Document Center

Mobile Platform as a Service:iOS FAQ

Last Updated:Jan 29, 2026

How to fix the HTML5 container positioning offset issue

Answer: If you encounter a positioning offset issue in the mPaaS container, update the settings as follows:

- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    // Skip LBS location.
    [LBSmPaaSAdaptor sharedInstance].shouldSkipLBSLocation = YES;

    .......
    
}

What to do if the preset offline package does not work with the H5_json.json file

Answer: The 10.1.32 baseline supports only the plist format. The 10.1.60 baseline supports both plist and JSON formats.

How to get information about installed offline package applications

Answer: Use the following code: NSDictionary *installedApps = [NAMServiceGet() installApps:nil];.

How to force an update of all offline package information

Answer: Use the encapsulated requestAllNebulaApps method to perform a full update.

[[MPNebulaAdapterInterface shareInstance]requestAllNebulaApps:^(NSDictionary *data, NSError *error) {

 }];

In iOS 13, the vux-ui pulldown component freezes when sliding in the HTML5 container

Answer: This issue occurs because it triggers a bug in UIWebview in the iOS system. Consider switching to WKWebView or replacing the frontend component. For more information, see Adapt to WKWebView for mPaaS 10.1.60.

How to view all registered JSAPIs and Plugins for the current application

Answer: Open an HTML5 page, go to the Xcode view hierarchy page, and run po [[PSDService sharedInstance] jsApis] in the lldb console to view all JavaScript APIs (JSAPIs). Similarly, run po [[PSDService sharedInstance] plugins] to view all registered Plugins.

1

How to get the UIViewController and WebView objects of the current HTML5 page in a JavaScript API or Plugin

Answer: During execution, a Plugin can directly access the event.context parameter, and a JavaScript API can access context. The PSDContext object contains all the information you need. For example, you can obtain a reference to the current controller with event.currentViewController or the current WebView with context.currentViewController.psdContentView.

image

How to get the startup parameters passed from the frontend when the current page loads

Answer: Retrieve the psdScene.createParam.expandParams property of the current View Controller (VC).

修改1.jpg

How to restrict a JavaScript API to work only in a specific offline package

Answer: In the JSAPI's execution method, retrieve the appId of the offline package for the current page. Then, decide whether to execute the logic.

image

How to intercept page URLs

Answer: Customize a Plugin and listen for an event to intercept URLs.

  • Event name to listen for:

    [PSDProxy addEventListener:kEvent_Proxy_Request_Start_Handler withListener:self useCapture:YES];
    `
  • Handle the interception:

    else if ([kEvent_Proxy_Request_Start_Handler isEqualToString:event.eventType]
          && [event isKindOfClass:[PSDProxyEvent class]] ){
          NSLog(@"-----kNBEvent_Scene_NavigationItem_Right_Setting_Click----");
          PSDProxyEvent *proxyEvent = (PSDProxyEvent*) event;
          NSMutableURLRequest *redirectReq = proxyEvent.request.mutableCopy;
          NSString *appId = event.context.currentSession.createParam.expandParams[@"appId"];
          NAMApp *app = [NAMServiceGet() findApp:appId version:nil];
          NSString *fallBackUrl = app.fallback_host;
          NSString *vhost = app.vhost;;
          NSString *url = redirectReq.URL.absoluteString;
          NSLog(@"url__%@______fallBackUrl:%@",url,fallBackUrl);
         if ([url containsString:@"www.baidu.com"]) {
             [proxyEvent preventDefault];
    }}

How to manually call a JavaScript API from native code

Answer: Directly call the `callHandler` method of the base class for the current page. The following code shows an example.

修改2.jpg

After publishing a new version of an offline package from the console, the client fails to load it

Answer: Before you troubleshoot this issue, ensure that you understand the offline package update mechanism. If the client fails to load the new package, an error may have occurred during the offline package rendering process. Troubleshoot the issue as follows:

  • Check the Remote Procedure Call (RPC) result for the full offline package update. In the console, search for bizType: 4 to view the offline package details and confirm that the latest package information from the console has been pulled.

  • If the previous step is successful, check if the offline package was decompressed successfully in the sandbox directory. If the offline package references content from a global resource package, the global resource package must also be in this directory. 8

  • If the offline package is not in the sandbox directory, temporarily disable offline package signature verification, delete the app, and run it again. If the package loads correctly after you disable signature verification, the signing private key and the client's verification public key do not match. Update the public key on the client.

  • If all the previous steps pass but the offline package update still fails, use Safari to debug the HTML5 page and find the specific cause of the error. Examples of errors include an incorrect path for the global resource package or a non-existent URL for the offline package. 9

Why do I see a blank screen or a 400 error when I open an offline package HTML5 page?

Answer: A blank screen or a 400 error usually indicates that the local offline package failed to load. The application then attempts to use the online fallback address. If the fallback address for the page does not exist, the page fails to load.

  • Follow the troubleshooting steps for offline packages to determine why the client failed to load the package.

  • To fix failures when loading the online fallback address, confirm that the correct offline package version was generated and uploaded to the console. This includes both regular offline packages and global resource packages. For more information, see Generate an offline package.

  • If a preset offline package fails to load from the online fallback address, ensure that the preset package is also uploaded to the console.

  • Ensure that the fallback_base_url in the local preset package information matches the fallback_base_url in the h5_json.json configuration file downloaded from the console. 1112

  • Also, ensure that the address created by concatenating fallback_base_url + main_url can be loaded in a browser.

    修改3.jpg

How to disable the swipe-to-go-back gesture for HTML5 pages

Answer: You can disable this feature from the frontend HTML5 page or from the native HTML5 container's base class.

  • To disable the swipe-back gesture for a specific frontend HTML5 page, call the setGestureBack JSAPI.

    AlipayJSBridge.call('setGestureBack',{val:false});
  • From the native HTML5 container's base class: In the base class's `viewDidAppear` method, call the system API to disable the swipe-to-go-back gesture and set the `guestBack` parameter. This method is suitable for scenarios where you need to disable the gesture for multiple or all HTML5 pages.

      - (void)viewDidAppear:(BOOL)animated {
          [super viewDidAppear:animated];
    
          self.options.gestureBack = NO;
          if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
              self.navigationController.interactivePopGestureRecognizer.enabled = NO;
          }
      }

How to determine if the current page is in a Mini Program

Answer: Retrieve the session for the current page and call the isTinyAppWithSession method. The following code shows an example:

PSDSession *session = self.psdSession;
BOOL isTinyApp = [NBUtils isTinyAppWithSession:session];

How to pass custom parameters to an HTML5 page

Answer: The following scenarios are based on the parameter passing method:

  • Native to H5: When you call the startH5ViewControllerWithParams method, pass the parameters as follows: [[MPNebulaAdapterInterface shareInstance] startH5ViewControllerWithParams:@{@"url": @"https://tech.antfin.com", @"key1":@"value1"}];.

  • Native to offline package: When you call the startH5ViewControllerWithNebulaApp method, pass the parameters as follows: [[MPNebulaAdapterInterface shareInstance] startH5ViewControllerWithNebulaApp:@{@"appId":@"70000000",@"param":@{@"key2":@"value2"}}];.

  • HTML5 to H5: When you call pushWindow, write the custom parameters in passData:

    AlipayJSBridge.call('pushWindow', {
    // The URL of the page to open
    url: 'https://m.taobao.com/',
    // Configuration parameters for opening the page
    param: {
      readTitle: true,    // Automatically read the title
      showOptionMenu: false,    // Hide the right-side menu
    transparentTitle:'always',
    },
    // Optional. Used to pass parameters to the new page.
    // On the new page, use AlipayJSBridge.startupParams to get passData.
    passData: {
      key1: "key1Value",
      key2: "key2Value"
    }
    });
  • HTML5 to offline package: When you call the startApp JSAPI, write the custom parameters in the param parameter:

    AlipayJSBridge.call('startApp', {
    appId: '70000000',
    param: {
    key1:'value1'
    }
    }, function(result) {
    // noop
    });

How to get parameters passed from an HTML5 page

Answer: There are two scenarios: retrieving parameters from the frontend and retrieving them from native code.

  • From the frontend: Use the startupParams method.

    // Startup parameters for the current page
    AlipayJSBridge.startupParams
  • From native code: Retrieve the parameters from the VC object for the current page.

    // Startup parameters for the current page
    NSDictionary *expandParams = self.psdScene.createParam.expandParams;
    NSLog(@"[mpaas] expandParams: %@", expandParams);

How to intercept JavaScript API calls

You can customize a plugin to listen for events.

  • Event name to listen for: kEvent_Invocation_Event_Start.

  • Handle the interception: Retrieve the name of the JSAPI, the parameters passed, and more.

    else if([kEvent_Invocation_Event_Start isEqualToString:event.eventType]) {
          PSDInvocationEvent * invocationEvent = (PSDInvocationEvent *)event;
          NSString * apiName = invocationEvent.invocationName;
          if([apiName isEqualToString:@"setOptionMenu"] || [apiName isEqualToString:@"showOptionMenu"] ) {
              NSLog(@"wwww");
          }
      }

How to handle the HTML5 container failing to be released when a WebView is nested on the home page

Background: In some special scenarios, you may need to nest the WebView of an offline package's HTML5 container in your app's home page. When the WebView's superview is destroyed, the HTML5 container may not be released. This can cause a memory leak.

Example code:

image.png

Answer: Handle this issue as follows:

image.png