IAPMiniProgram SDK

Common for both Android and iOS

The following FAQs are common for IAPMiniProgram SDK on both Android and iOS.

How to customize text content on the authorization views that is triggered by the my.getAuthCode JSAPI?

See the following documents for implementation details:

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.

The code is as follows:

copy
<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?

Try the following ways to resolve this problem:

  • Way 1:

In mp_config in the iapconnect_config_full file, set the prerender_2_0 parameter to false to disable prerendering of the applet. This can temporarily resolve this problem.

  • Way 2:

Update the SDK version to 2.67.0 or later.

Is there any security issues if the filterTouchesWhenObscured parameter set to false ?

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?

Try the following ways to disable the gesture back function:

  • Way 1:

Handle it at the native layer. Add the following code when opening the mini-program: startParams["gestureBack"] = false. This disables the side-slide back function in all mini-programs.

Code sample as follows:

copy
  var startParams: [String: Any] = [:]
  startParams["gestureBack"] = false
  
  let vc = (try? GRVAppContainerLaunch.sharedInstance().openApp(
      withAppId: "*****",
      extraParams:startParams,
      error: ()
  )) ?? UIViewController()
  
  self.navigationController?.pushViewController(vc, animated: true)

  • Way 2

On the mini program side, you can limit a mini program to prohibit gesture back. In the app.json file, in the window parameter, add the following code: "gestureBack": "NO".

copy
  "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.

  1. Declare the userAgent property.
copy
/// Custom userAgent definition
@property (nonatomic, copy, nullable) NSString *userAgent;
  1. Implement the user agent configuration.
copy
func createGriverConfiguration() -> GRVConfiguration {
    let configuration = GRVConfiguration()
    configuration.userAgent = "Custom_UA/iOS"  // Custom UA pattern
    return configuration
}

Configure for Android

Call the setAppendUserAgent API before 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 examples:

  • 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 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.

Is there a way to disable the debug mode from viewing the return value of JSAPI?

Try one of the following solutions:

  • Rely on the super app. If super app turns off/disable the debug mode. SDK will also automatically turn off/disable the debug function.
  • Both Android and iOS release packages turn off/disable the 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:

Is it possible to disable the Ant secure compiler? If not, what modules and libraries are protected by this tool?

The Ant secure compiler can not be disabled.

This tool only protects the IAPSecurityGuardLite library. It is the wireless bodyguard security components, mainly used to add the 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.

copy
{
    "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 supports the overseas Google maps?

The Map component can be integrated to support the Google map capabilities in your mini programs. For details, see the following topics:

How to close a single session, especially the currentSession current session?

  • To close the current session, use the exitSession method as the following code:
copy
(void)exitSession:(RVASession *)session animated:(BOOL)animated;
  • To close the first latest or first of active session, use the following code:
copy
[[RVAContextGet() sessionManager] exitSession:[RVAContextGet() sessionManager].currentSession animated:NO];

How to change the status bar color on the 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 the status bar color to red.

copy
public static void openUrl(Context context, String url, Bundle bundle) {
  bundle.putInt("statusBarColor",0xff0000)
}

Why the Authorization window cannot pop up in a mini program?

Use the my.getAuthCode JSAPI to obtain the authorization code, and then there is an authorization window pop-up. For more information, see the my.createWebViewContext JSAPI topic.

Sample code as follows.

copy
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)
      },
    });
  },