IAPMiniProgram SDK
Common for both Android and iOS
The following FAQ topics are common for IAPMiniProgram SDK on both Android and iOS.
How to customize text content in the authorization views that is triggered by the my.getAuthCode JSAPI?
See the following documents for implementation details:
- For Android: Customize user authorization views
- For iOS: Customize user authorization views
How to resolve the problem that non-numbers can be pasted when the input box type
= number?
To solve this problem, you can add the controlled attribute to the input
element.
Code sample:
<input
maxlength="10"
type="number"
name="input"
onInput="validate"
class=" input-value"
placeholder="{tplaceholder}}
value="{ {value}}"
controlled
>
How to resolve the problem that the offline package cannot be used when the old offline package of Pilot testing is cancelled?
You can try the following two options to resolve the issue:
- Disable prerendering: In
mp_config
in the iapconnect_config_full file, set theprerender_2_0
parameter tofalse
to disable prerendering of the applet. This can temporarily resolve the problem. - Update the SDK: Update the SDK version to 2.67.0 or later.
Are there any security risks if the filterTouchesWhenObscured parameter is set to false
?
No, there are no security issues.
We attach great importance to the user's security experience. For the touch area operation in the mini program, we have established a strict security risk control mechanism to ensure the security of the user interaction process.
At the same time, we also have a unified security audit system internally to ensure the safety of users.
Regarding the "Security issue of touch hijacking incident" prompted by the security scan, there is no risk.
How to disable the gesture-back function in mini programs?
You can disable the gesture-back function in the following two ways:
- Native layer configuration: When opening a mini-program, add
startParams["gestureBack"] = false
. This disables the side-slide back function in all mini-programs.
Code sample:
var startParams: [String: Any] = [:]
startParams["gestureBack"] = false
let vc = (try? GRVAppContainerLaunch.sharedInstance().openApp(
withAppId: "*****",
extraParams:startParams,
error: ()
)) ?? UIViewController()
self.navigationController?.pushViewController(vc, animated: true)
- Mini program configuration: In the app.json file, in the
window
parameter, add the following code:"gestureBack": "NO"
.
Code sample:
"window": {
"backgroundColor": "#ffffff",
"pullRefresh": false,
"allowsBounceVertical": "YES",
"titleBarColor": "#fff",
"gestureBack": "NO"
},
How to set a custom User-Agent in the SDK?
When working with the SDK, you may need to customize the User Agent(UA) for loading mini program pages in Android or iOS.
Configure for iOS
Follow these steps. For more information, see the userAgent property.
- Declare the userAgent property.
/// Custom userAgent definition
@property (nonatomic, copy, nullable) NSString *userAgent;
- Implement the user agent configuration.
func createGriverConfiguration() -> GRVConfiguration {
let configuration = GRVConfiguration()
configuration.userAgent = "Custom_UA/iOS" // Custom UA pattern
return configuration
}
Configure for Android
Call the setAppendUserAgent API before initializing the SDK. For details, see the setAppendUserAgent API for Android.
How to resolve back navigation issues in SDK when returning to the previous page after opening a new one?
Background
When using the SDK to navigate between pages, returning to the previous page sometimes does not restore the original state of the mini program page. For example:
- From a mini program page, navigate to a WhatsApp link and then return.
- The back navigation does not restore the correct mini program page as expected.
- The same URL works correctly in the Safari browser.
Reason
The issue occurs because the webpage source code uses target="_blank"
for links.
In browsers like Safari, target="_blank"
opens a new window or WebView, preserving the original page state in the previous WebView instance.
When using the mini program SDK, the container only uses a single WebView instance. Opening a new URL replaces the existing WebView content instead of creating a new one.
As a result, when navigating back within the SDK container, the previous page URL is refreshed, losing the original page state.
Solutions
- Avoid using
target="_blank"
in the links of the affected webpages. - Instead, keep the navigation within a single flow to align with the SDK WebView behavior.
Can I disable debug mode from viewing the return value of JSAPI?
Try one of the following solutions:
- Rely on the super app. If the super app turns off/disables debug mode, the SDK will also automatically turn off/disable the debug function.
- Both Android and iOS release packages turn off/disable debug mode.
How to use the video tag on a real device?
To allow users to play videos in your mini programs, you need to integrate the Video
component into your project. For details, see the following topics:
Can I disable the Ant secure compiler? If not, what modules and libraries are protected by this tool?
No. The Ant secure compiler only protects the IAPSecurityGuardLite
library. It is the wireless bodyguard security components, mainly used to add signing verification features.
How to configure the mini program navigation bar?
You can set the transparentTitle property in the app.json file. For more information, see the Global configuration > window topic.
{
"transparentTitle"; "always",
}
// none: The navigation bar is opaque, with no transparency effect.
// always: The navigation bar is always transparent (or semi-transparent), regardless of whether the page is scrolled.
// auto: When the page scrolls up, the navigation bar background has a gradient effect.
Does the container SDK support the overseas Google Maps?
Yes. The Map
component can be integrated to support the Google map capabilities in your mini programs. For details, see the following topics:
- Android: Integrate the map component
- iOS: Integrate the map component
How to close a single session, especially the currentSession
current session?
- To close the current session, use the exitSession method as the following code:
(void)exitSession:(RVASession *)session animated:(BOOL)animated;
- To close the first latest or first of active session, use the following code:
[[RVAContextGet() sessionManager] exitSession:[RVAContextGet() sessionManager].currentSession animated:NO];
How to change the status bar color on an opened H5 page?
Use the openUrl method as the following code. For example, set the value of the statusBarColor parameter as 0xff0000
, which changes the status bar color to red.
public static void openUrl(Context context, String url, Bundle bundle) {
bundle.putInt("statusBarColor",0xff0000)
}
Why doesn't the authorization window appear in a mini program?
Use the my.getAuthCode JSAPI to obtain the authorization code and to trigger the authorization popup. For more information, see the my.createWebViewContext JSAPI topic.
Code sample:
onLoad(query) {
// page loading
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
this.requestPlatformInfo();
this.getEasonInfo();
this.webViewContext = my.createWebViewContext('web-view-shoplazza');
},
getEasonInfo(){
my.getAuthCode({
scopes: ['auth_user'],
success: (res) => {
console.log("res::::", res);
my.alert({
content: res,
});
},
fail: (res) => {
my.alert({
title: 'failed',
content: res.authErrorScopes
});
console.log(res.authErrorScopes)
},
});
},