Integrate SDK components

By integrating Android IAPMiniProgram SDK, the basic capabilities of mini-programs are included in your project. However, due to package size concerns, enhanced capabilities of Android IAPMiniProgram SDK are not included by default.

You can enhance the SDK capabilities by integrating the following pre-defined SDK components:

Notes:

  • If a component is not integrated, mini programs will encounter errors when calling JSAPIs related to the component.
  • For third-party super apps, if you do not integrate certain components, it is recommended to remove the related JSAPI documentation from your documentation center to avoid unexpected errors.

Integrate the Map component

To allow users to call Google Maps in your mini-programs, you need to integrate the Map component into your project by taking the following steps:

Step 1: Integrate Google Maps SDK

You need firstly integrate Google Maps SDK by taking the following steps:

  1. Get a Google API key. For step-by-step instructions, see Using API Keys in Google's documentation.
  2. Save the API key to the local.properties file as below.
copy
MAPS_API_KEY=YOUR_API_KEY
  1. Update the build.gradle file to inject the mapsApiKey variable into the AndroidManifest.xml file as below.
copy
android {
    defaultConfig {
        // ...
        // Set the properties within 'local.properties' into a 'Properties' class so that values
        // within `local.properties` (e.g. Maps API key) are accessible in this file.
        Properties properties = new Properties()
        if (rootProject.file("local.properties").exists()) {
           properties.load(rootProject.file("local.properties").newDataInputStream())
        }
        manifestPlaceholders = [ mapsApiKey : properties.getProperty("MAPS_API_KEY", "") ]
    }
}

Step 2: Add the Maven repository

Add the Maven repository in your root build.gradle file with the following code:

copy
repositories{
    jcenter()
}

Step 3: Add the Maps dependencies

Add the Maps dependencies in the app-level build.gradle file with the following code:

copy
dependencies {
    implementation "com.alipay.plus.android:iapminiprogram-gmap:${iapminiprogram_version}"
}

(Optional) Step 4: Prevent specific mini-programs from using your app's API key

If a mini-program does not provide a Google API key, your app's API key is used by default. To avoid charging your app unreasonable fees on Google Maps services used in specific mini-programs, you need to prevent the mini-programs from using your app's API key. Take the following steps:

  1. Implement GriverMapCustomAPIKeyExtension with either of the following codes:

Kotlin

copy
class DemoGriverMapCustomAPIKeyExtension: GriverMapCustomAPIKeyExtension {
    override fun canUseGoogleAPIKey(appId: String?): Boolean {
        return false
    }
}

Java

copy
public class DemoGriverMapCustomAPIKeyExtension implements GriverMapCustomAPIKeyExtension {
    @Override
    public boolean canUseGoogleAPIKey(String appId) {
        return false;
    }
}
  1. Register the Extension after the SDK is initialized as below.
copy
Griver.registerExtension(new GriverExtensionManifest(GriverMapCustomAPIKeyExtension.class, new DemoGriverMapCustomAPIKeyExtension()));

More information

For more information about the Map components, see the following documents:

Integrate the Video component

To allow users to play videos in your mini-programs, you need to integrate the Video component into your project.

Add the Video dependencies in the app-level build.gradle file with the following code:

copy
dependencies {
    implementation "com.alipay.plus.android:iapminiprogram-video:${iapminiprogram_version}"
}

For more information about the Video component, see my.createVideoContext.

Integrate the Lottie component

To allow users to implement the Lottie capabilities in your mini-programs, you need to integrate the Lottie component into your project.

Add the Lottie dependencies in the app-level build.gradle file with the following code:

copy
dependencies {
    implementation "com.alipay.plus.android:iapminiprogram-lottie:${iapminiprogram_version}"
}

For more information about the Lottie component, see my.createLottieContext.

Integrate the Livestreaming component

To allow users to play live-streaming videos in your mini-programs, you need to integrate the Livestreaming component into your project.

Add the Livestreaming dependencies in the app-level build.gradle file with the following code:

copy
dependencies {
    implementation "com.alipay.plus.android:iapminiprogram-media:${iapminiprogram_version}"
}

For more information about the Livestreaming component, see my.createLivePlayerContext.

Integrate the Bluetooth component

To allow users to implement the Bluetooth capabilities in your mini-programs, you need to integrate the Bluetooth component into your project.

Add the Bluetooth dependencies to the app-level build.gradle file with the following code:

copy
dependencies {
    implementation "com.alipay.plus.android:iapminiprogram-bluetooth:${iapminiprogram_version}"
}

For more information about the Bluetooth component, see Bluetooth JSAPIs.

Integrate the Biometric Authentication component

To enable users to implement biometric authentication capabilities in your mini programs, you must integrate the Biometric Authentication component into your project.

Before integrating, ensure that your Android IAPMiniProgram SDK version is 2.51.0 or later. Then add the Biometric Authentication dependencies to the app-level build.gradle file with the following code:

copy
dependencies {
  implementation "com.alipay.plus.android:iapminiprogram-bioauth:${iapminiprogram_version}"
}

During your app packaging process, the SDK can automatically include the following <uses-permission> elements in the app's manifest file:

copy
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />

For more information about the Biometric Authentication component, see Biometric authentication API overview.