Integrate SDK components
By integrating the iOS IAPMiniProgram SDK, the basic capabilities of mini-programs are included in your project. However, due to package size and App Store reviewing concerns, enhanced capabilities of the iOS IAPMiniProgram SDK are not included by default.
You can enhance the SDK capabilities by integrating the following pre-defined SDK components:
- Map: This component allows users to implement the Google Map capabilities in your mini-programs. For more information, see Integrate the Map component.
- Video: This component allows users to play videos in your mini-programs. For more information, see Integrate the Video component.
- Lottie: This component allows users to implement the Lottie capabilities in your mini-programs. For more information, see Integrate the Lottie component.
- Livestreaming: This component allows users to play live-streaming videos in your mini-programs. For more information, see Integrate the Livestreaming component.
- Bluetooth: This component allows users to implement the Bluetooth capabilities in your mini-programs. For more information, see Integrate the Bluetooth component.
- Biometric Authentication: This component allows users to implement the biometric authentication capabilities in your mini programs. For more information, see Integrate the Biometric Authentication component.
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 evoke a map in your mini-programs, you need to integrate the Map component into your project. For iOS users, two maps are supported to be integrated:
- Google Maps: Read this section to learn about how to integrate Google Maps into your app.
- Apple Maps: Read this section to learn about how to integrate Apple Maps into your app.
Google Maps
Step 1: Add a key to the plist file
Due to the limitations of the iOS system, you must add a specific key with a privacy description to the plist file before using the capabilities. For example, to use location capabilities, you must add the following keys:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>...</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>...</string>
Step 2: Import the Map component
Then, you need to import the Map component of the iOS IAPMiniProgram SDK into your project. Refer to the following sample code:
let configuration = GRVConfiguration()
configuration.apiKeyForGoogleMaps = "YOUR_API_KEY"
// Make sure your default coordinates are relevant
configuration.defaultCoordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0)
When using the sample code above, take the following things into consideration:
- Package size: The Map component contributes approximately 426 KB to your binary product (arm64 arch).
- Properties: When initializing IAPMiniProgram SDK, two properties of
GRVConfiguration
(apiKeyForGoogleMaps and defaultCoordinate) must be set correctly:
- apiKeyForGoogleMaps: Indicates the Google API key that is required for using Google Maps. To get a Google API key, see Using API Keys in Google's documentation.
- defaultCoordinate: Indicates the default coordinates, including latitude and longitude. Make sure your default coordinates are relevant.
(Optional) Step 3: 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.
Implement GRVMapCustomAPIKeyDelegate
with the following code:
class DemoCustomAPIKeyDelegate: NSObject, GRVMapCustomAPIKeyDelegate {
func canUseGoogleAPIKey(forApp appId: String) -> Bool {
return false
}
}
More information
For more information about the Map components, see the following documents:
Apple Maps
To allow users to evoke Apple Maps in your mini-programs, update your Podfile with the following code:
pod 'IAPMiniProgram/AppleMap'
For more information about the Map-related JSAPI, see my.createMapContext.
Integrate the Video component
To allow users to play videos in your mini-programs, you need to integrate the Video component into your project.
Update your Podfile with the following code:
pod 'IAPMiniProgram/Video'
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.
Update your Podfile with the following code:
pod 'IAPMiniProgram/Lottie'
For more information about the Map-related JSAPI, see my.createMapContext.
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.
Update your Podfile with the following code:
pod 'IAPMiniProgram/Media'
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.
Update your Podfile with the following code:
pod 'IAPMiniProgram/Bluetooth'
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 iOS IAPMiniProgram SDK version is 2.51.1 or later. Then complete the following two tasks to integrate this component:
Add a key to the plist file
To use facial recognition capability on iOS devices, you must include the NSFaceIDUsageDescription
key in your app's Info.plist file and provide a purpose string for this key. To add the key, refer to the following sample code:
<key>NSFaceIDUsageDescription</key>
<string>...</string>
Update Podfile
Update your Podfile with the following code:
pod 'IAPMiniProgram/BioAuth'
More information
For more information about the biometric authentication component, see Biometric authentication API overview.