iOS
Is there any way to set isInspectable
in iOS webview?
Yes. You can realize this by setting the enableSafariInspector property in the SDK initialization. This property allows the super app to configure the Safari inspector for production builds.
The code is as follows :
[GRVAppContainerLaunch sharedInstance].configuration.enableSafariInspector = YES;
How to resolve the problem that iOS SDK cannot obtain appid
through context?.miniProgramInfo?.appId
?
It is possible that appId
cannot be obtained from context?.miniProgramInfo?.appId
, because miniProgramInfo
is of the optional type.
Try to use the following code to obtain the appId
:
IAPGriverRuntimeContext *pubicGriverContext =[IAPGriverRuntimeContext sharedInstance];
NSString * appId = pubicGriverContext.appId;
Is there a way to hide a mini program in iOS SDK?
Currently, the SDK does not provide a corresponding method to hide a mini program.
How to resolve the problem that when a link is loaded in the iOS webview and the back button cannot be clicked?
If you click the back button on a specific URL, but it does not allow you to return. To solve this issue, you can listen for the back event on the H5 side.
Refer to the following code to add a back event listener on the H5 side:
document.addEventListener("back", function (e) {
e.preventDefault();
if (window.history.length > 2) {
window.history.go(-2);
return false;
} else {
AlipayJSBridge.call('popWindow');
}
});
How to implement the solution of a mini program jumping to a third-party app on iOS?
- On the iOS side of the super app, you need to implement the GRVURLNavigationEventDelegate class. For more information, see the Listen for the URL navigation event topic.
The specific code is as follows:
import UIKit
class DemoURLNavigationEventDelegate: NSObject,GRVURLNavigationEventDelegate {
func urlListOpenByApplication() -> [String] {
return [ "^http(s)?://whatsapp[.]com[.]*"]
}
func urlListOpenByContainer() -> [String] {
return [];
}
func willStartURLNavigation(_ context: GRVNavigationContext) -> Bool {
if let url = context.url, url.absoluteString.hasPrefix("https://www.google.com") {
print("App manage it!")
return true
}
return false
}
func allowLoadURLWithoutPermissionCheck(_ url: URL?) -> Bool {
#if CODE_DEMO_PROJECT
var urlWhiteListRegexp = ""
urlWhiteListRegexp = UserDefaults.standard.string(forKey: "url_regexp") ?? ""
do {
guard let host = url?.host else { return false }
let regExpr = try NSRegularExpression (pattern: urlWhiteListRegexp, options: .caseInsensitive)
let matched = regExpr.firstMatch(in: host, range: NSRange(location: 0, length: host.count)) != nil
return matched
} catch let error as NSError {
print(error)
return false
}
#endif
// check the url and decide to allow or not
return false
}
}
- Implement GRVExtensionDelegate during SDK initialization.
let extensionDelegate = GRVExtensionDelegate()
extensionDelegate.urlNavigationEventDelegate = DemoURLNavigationEventDelegate()
How to fix the issue of missing permission pop-ups for JSAPIs in mini programs on iOS?
Background:
The following is the wrong code logic that causes this issue:
let vc = (try? GRVAppContainerLaunch.sharedInstance().openApp(
withApppId: "mini program ID",
extraParams: [:],
error: ()
)) ?? UIViewController()
// The correct is : self.navigationController?.pushViewController
self.present(vc, animated: true)
Solution to fix this issue:
Use self.navigationController?.pushViewController
(navigation stack presentation) to replace the wrong self.present
(modal presentation).
let vc = (try? GRVAppContainerLaunch.sharedInstance().openApp(
withApppId: "mini program ID",
extraParams: [:],
error: ()
)) ?? UIViewController()
self.navigationController?.pushViewController(vc, animated: true)
How to resolve the security scanning issue related to ZipArchive in iOS IAPMiniProgram SDK?
Upgrade the iOS IAPMiniProgram SDK version to 2.67.0 or later. For details about the SDK version, see iOS release notes.
How to resolve the issue of the page automatically enlarging when entering information (input
) in the mini program on the iOS side?
Try the following ways to resolve this issue:
Ways | Solution |
1st | Update the Refer to the code sample:
|
2nd | Add the following mobile meta viewport settings to the HTML file of the WebView: |
Why cannot intercept the iOS swipe back function?
When swiping back on iOS, the back event cannot be triggered because the gesture operation (in progress) can be undone mid-way.
How to resolve the problem that the iOS client fails to redirect when calling my.redirectTo JSAPI with query parameters through Deeplink?
The reason for this problem is that the page resources are not been fully loaded when executing the my.redirectTo JSAPI in the onReady method.
Try the following ways to resolve this problem:
Ways | Solution |
1st | Add a delay of 300ms as follows: copy
|
2nd | Upgrade the iOS IAPMiniProgram SDK version to 2.66.0 or later. For details about the SDK version, see iOS release notes. |
In iOS SDK, do the setTitleBarColor and setTitleColor functions support transparency, and what is the usage of the setBackButtonColor function?
- The setTitleBarColor and setTitleColor function can pass transparency. On iOS, they are in ARGB format. You only need to pass a number object.
- The setBackButtonColor function sets the text color of the back button color on the title bar.
Does the mini program support Google ads?
YES. Google ads is supported.
How to resolve the issue of Google Ads failing to load in H5 container pages on iOS side?
- Append the
safeInjectFetch=true
parameter to the target URL that is opening in the H5 container WebView. - Modify the URL as follows: https://<your-target-url>.com?safeInjectFetch=true
How to resolve errors when specific links fail to load in iOS H5 container pages but work properly on Android?
Implement the GRVSchemeTaskHandlerDelegate in the iOS application and return false
for the problematic URLs by using the delegate method schemeTaskHandlerEnabled.
class DemoSchemeTaskHandlerDelegate: NSObject, GRVSchemeTaskHandlerDelegate {
func schemeTaskHandlerEnabled(forURL url: String) -> Bool {
var enable = true
if let u = URL(string: url), let host = u.host() {
let blackList = [
"url"
]
return !blackList.contains(host)
}
return true
}
}
How to know the SDK version information of iOS ?
Check the IAPConnectSDKVersion file, where the IAPConnectSDKInfo indicates the version information.
How to resolve security scan issues related to innerHTML risk in the iOS IAPMiniProgram SDK?
To mitigate this risk, you can override the SDK default error page by implementing a custom error page in your super app. The custom error page is rendered to replace the SDK default page, improving security and ensuring compliance with your app policies.
For details, see the Customize error pages topic.
How to run a mini program in an iOS simulator?
You can run a mini program in an iOS simulator by modifying the mini.project.json configuration file and setting the enableAppxNg value to true
.
How to solve errors when using crypto for RSA-SHA256 encryption on iOS?
You can use the jsrsasign
library as an alternative implementation for RSA-SHA256 encryption.
How to fix the issue that clicking an email link (a mailto:
link) blocks the page from loading in iOS mini programs?
This issue occurs because iOS mini programs restrict non-HTTPS links for security. To customize access rules and allow email links, implement the GRVNetworkRequestAllowDelegate
protocol. For implementation details, refer to Customize web-view access to HTTP resources and URL schemes.