This topic describes common issues and their solutions for iOS integration.
Notes
When you initialize the HTML5 container, specify the base class for all HTML5 pages and the base class for the WebView to enable unified processing.

When frontend developers create offline packages, do not use Chinese characters in paths or file names. Otherwise, the client will fail to decompress the offline package.
The absolute length of each resource path in an offline package must not exceed 100 characters. Otherwise, the client will fail to decompress the tar package, and a blank page will appear.
How to fix HTML5 container positioning offset issues
Answer: You may encounter positioning offset issues when you use the mPaaS container. To fix this issue, update the settings as follows:
- (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Skip LBS location
[LBSmPaaSAdaptor sharedInstance].shouldSkipLBSLocation = YES;
.......
}The H5_json.json file for a preset offline package does not take effect
Answer: In baseline 10.1.32, only the plist format is supported. In baseline 10.1.60, both plist and JSON formats are supported.
How to get information about installed offline package applications
Answer: You can use the following sample code: NSDictionary *installedApps = [NAMServiceGet() installApps:nil];.
How to force an update of all offline package information
Answer: You can use the encapsulated requestAllNebulaApps method to perform a full update.
[[MPNebulaAdapterInterface shareInstance]requestAllNebulaApps:^(NSDictionary *data, NSError *error) {
}];What to do when the vux-ui pulldown component freezes on scroll in the HTML5 container on iOS 13
Answer: This issue occurs because of a bug in UIWebview on iOS. You can resolve this by switching to WKWebView or replacing the frontend component. For more information about how to switch to WKWebView, see Adapt to WKWebView for mPaaS 10.1.60.
How to view all JavaScript APIs and Plugins registered for the current application
Answer: Open an HTML5 page and go to the Xcode View Hierarchy page. In the lldb console, run po [[PSDService sharedInstance] jsApis] to view all JavaScript APIs. Similarly, you can run po [[PSDService sharedInstance] plugins] to view all registered Plugins.
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 retrieve the event.context parameter, and a JavaScript API can retrieve the context parameter. From the PSDContext object, you can obtain all the information or references you need. For example, you can obtain a reference to the current controller using event.currentViewController or a reference to the current WebView using context.currentViewController.psdContentView.

How to get the WebView of the current page
Answer: The WebView of the current HTML5 page is a property of the current view controller (VC). You can retrieve it using vc.psdContentView. In a JavaScript API or Plugin, you can use the method described previously to retrieve the VC of the current page.
When you retrieve the WebView of the current page in the HTML5 page base class, do so in the viewWillAppear method. The WebView is not created in the viewDidLoad method. If you use the viewDidLoad method, the value returned is nil.

How to get the startup parameters passed by the frontend when the current page loads
Answer: You can directly retrieve the psdScene.createParam.expandParams property of the current VC.

How to restrict a JavaScript API to a specific offline package
Answer: In the execution method of the JavaScript API, retrieve the appId of the offline package to which the current page belongs. Then, you can decide whether to execute the logic.
How to intercept a page URL
Answer: You can create a custom Plugin and listen for events.
Listen for the event:
[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 intercept the URL of the current HTML5 page before it loads
Answer: In the base class of the HTML5 page, you can implement the delegate method for the UIWebView lifecycle. Listen for the kEvent_Navigation_Start event to intercept the URL before the page loads. Then, you can retrieve the WebView and URL of the current page to perform the required processing.

How to manually call a JavaScript API from Native code
Answer: Sometimes, you may need to manually call a JavaScript API from the native client on the current page. To do this, you can call the following interface of the current VC.

Why does a local preset offline package fail to load?
Answer: A preset resource package usually fails to load because the package version and package information do not match. When you test a local preset offline package, first disconnect from the network. This action prevents the offline package from being updated and ensures that the local preset version on the client is loaded.
Check whether the information of the local preset offline package is consistent with the package information configured in the Plist file. This includes information such as app_id, version, and main_url.
Why does the client fail to load a new offline package after it is published in the console?
Answer: Before you review the solution, make sure you understand the update principle of offline packages. The client may fail to load a new package because an error can occur at any stage of the offline package rendering process. Troubleshoot the issue as follows:
View the Remote Procedure Call (RPC) return result for the full offline package update. In the console, search for "bizType: 4" to check the returned offline package details. Confirm that the latest package information published in the console has been pulled.
If the previous step is successful, check the offline package information in the finish callback method for loading the offline package. Make sure that it is the latest package published in the console, the value of error is nil, and the app_id, version, and main_url are correct.
If the previous step is successful, check whether the offline package is successfully decompressed in the sandbox directory. If the current offline package references content from a global resource package, the global resource package must also be in this directory.

If the corresponding offline package is not in the sandbox directory, temporarily disable signature verification for the offline package, delete the app, and run it again. If the package loads normally after you disable signature verification, the private key used for adding the signature to the offline package does not match the public key used for signature verification on the client. In this case, you must update the public key information on the client.

If all the preceding steps are successful but the offline package update still fails, use Safari to debug the HTML5 page and view the specific cause of the error. For example, the global resource package path may be incorrect, or the URL for loading the offline package may not exist.

Global resource package fails to load
Answer: If you determine that the global resource package fails to load during Safari debugging, troubleshoot the issue as follows:
Check whether the global resource package is registered.
If the previous step is successful, check whether the offline package is successfully decompressed in the sandbox directory.

Check whether the path of the resource file in the referenced global resource package is valid. Make sure that the reference path does not contain Chinese characters.
Why does an offline package HTML5 page show a blank screen or a 400 error?
Answer: A blank screen or a 400 error usually occurs because the local offline package fails to load. This failure causes the online fallback address to be used. However, if the fallback address for the page does not exist, the page fails to load.
Follow the offline package troubleshooting steps described previously to identify why the client offline package failed to load.
To resolve the issue of a failed online fallback address, confirm that the correct offline package version is generated and has been uploaded to the console. This applies to both regular offline packages and global resource packages. For more information, see Generate an offline package.
If a preset offline package fails to use the online fallback address, make sure the preset offline package is also uploaded to the console.
Make sure that the
fallback_base_urlin the local preset package information is the same as thefallback_base_urlin the h5_json.json configuration file downloaded from the console.

Make sure that the address formed by concatenating fallback_base_url and
main_urlcan be loaded in a browser.
How to disable the swipe-to-go-back gesture for an HTML5 page
Answer: You can disable this feature from the frontend HTML5 page or from the native HTML5 container base class.
Disable from the frontend HTML5 page: Call the setGestureBack JavaScript API. This method is suitable for scenarios where you need to disable the swipe-to-go-back gesture for a specific page.
AlipayJSBridge.call('setGestureBack',{val:false});.Disable from the native HTML5 container base class: In the viewDidAppear method of the base class, call the system interface 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 swipe-to-go-back 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 of the current page and call the isTinyAppWithSession interface to make the determination. The following is a code sample:
PSDSession *session = self.psdSession;
BOOL isTinyApp = [NBUtils isTinyAppWithSession:session];How to pass custom parameters to an HTML5 page
Answer: The method depends on how you pass the parameters. The following scenarios are supported:
Native to HTML5: When you call the
startH5ViewControllerWithParamsmethod, you can pass the parameters as follows:[[MPNebulaAdapterInterface shareInstance] startH5ViewControllerWithParams:@{@"url": @"https://tech.antfin.com", @"key1":@"value1"}];.Native to offline package: When you call the
startH5ViewControllerWithNebulaAppmethod, you can pass the parameters as follows:[[MPNebulaAdapterInterface shareInstance] startH5ViewControllerWithNebulaApp:@{@"appId":@"70000000",@"param":@{@"key2":@"value2"}}];.HTML5 to HTML5: When you call
pushWindow, you can write the custom parameters inpassData.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, you can use AlipayJSBridge.startupParams to get passData passData: { key1: "key1Value", key2: "key2Value" } });HTML5 to offline package: When you call the startApp JavaScript API, you can write the custom parameters in param.
AlipayJSBridge.call('startApp', { appId: '70000000', param: { key1:'value1' } }, function(result) { // noop });
How to get passed parameters on an HTML5 page
Answer: There are two scenarios: retrieving parameters from the frontend and retrieving them from the native code.
Retrieve from the frontend: Use the
startupParamsmethod to retrieve the startup parameters of the current page.AlipayJSBridge.startupParamsRetrieve from the native code: Retrieve the parameters through the VC object of the current page.
// Startup parameters of the current page NSDictionary *expandParams = self.psdScene.createParam.expandParams; NSLog(@"[mpaas] expandParams: %@", expandParams);
How to intercept a JavaScript API call
Answer: You can create a custom Plugin and listen for events.
Listen for the event:
kEvent_Invocation_Event_Start.Handle the interception: Retrieve the JavaScript API name, passed parameters, and other information.
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"); } }