Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

(Optional) Use Griver capabilities

This topic introduces how to import the optional subspecs of ACGriverCore to use Griver Bluetooth and map capabilities.

Overview

After the integration of IAPConnect, Griver's core capabilities are included in your project. However, for package size and App Store reviewing concerns, optional Griver capabilities are not included by default. These capabilities are within optional subspecs of ACGriverCore. You may integrate these capabilities by updating your Podfile, as shown below:

copy
source 'https://cdn.cocoapods.org/'
source 'YOUR_COCOAPODS_CDN_SOURCE_URL'

target 'YOUR_TARGET' do
  # required
  pod 'IAPConnect', '2.0.0'
  
  # required
  pod 'IAPConnectResourceAppStore', '2.0.0'
  
  # optional
  pod 'ACGriverCore/Bluetooth'
  
  # optional
  pod 'ACGriverCore/Map'
end

For more information about YOUR_COCOAPODS_CDN_SOURCE_URL, refer to Add Alipay+ SDK to your project.

As ACGriverCore is already a dependency of IAPConnect, its default subspecs are imported automatically. However, optional subspecs of ACGriverCoreneed to be imported manually. Currently, there are two optional subspecs of ACGriverCore: Bluetooth and Map. The following sections discuss these two optional subspecs in detail.

ACGriverCore/Bluetooth

This subspec contains the Bluetooth capability of Griver. If this subspec is not imported into your project, your mini program would encounter error 1 (JSAPI not existed) when calling Bluetooth-related JSAPIs.

For the complete list of Bluetooth JSAPIs, refer to Bluetooth API Overview.

Note: Package size concern: ACGriverCore/Bluetooth contributes approximately 149 KB to your binary product (arm64 arch).

ACGriverCore/Map

This subspec contains the map capability of Griver. If this subspec is not imported into your project, your mini program would encounter error 1 (JSAPI not existed) when calling map-related JSAPIs.

For the complete list of map-related JSAPIs, refer to my.createMapContext.

Prerequisites

Due to the limitations of the iOS system, you must add a specific privacy description key to the plist file before using the above capabilities. For example, to use location capabilities, you must add the following keys:

copy
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>...</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>...</string>

Import ACGriverCore/Map

Things to know when importing the ACGriverCore/Map subspec are listed below:

  • Package size concern: ACGriverCore/Map contributes approximately 426 KB to your binary product (arm64 arch).
  • Griver map is using Google Maps. When this subspec is imported, Google Maps will be included in your project too.
  • When initializing Griver, two properties of GRVConfiguration (apiKeyForGoogleMaps and defaultCoordinate) must be set:
    • apiKeyForGoogleMaps: Indicates the Google API key required to use the Google Maps service. To get an API key, follow Google's instructions.
    • defaultCoordinate: Indicates the default coordinates, including latitude and longitude. Make sure your default coordinates are relevant.

See the following sample code:

copy
let configuration = GRVConfiguration()
configuration.apiKeyForGoogleMaps = "YOUR_API_KEY"
// Make sure your default coordinates are relevant
configuration.defaultCoordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0)

(Optional) Prevent mini program from using API key

If a mini program does not provide gAPIKey, the super app's API key (in GRVConfiguration) will be used by default. To prevent certain mini programs from using its API key, the super app can implement GRVMapCustomAPIKeyDelegate, as shown in the sample code below:

copy
class DemoCustomAPIKeyDelegate: NSObject, GRVMapCustomAPIKeyDelegate {
    func canUseGoogleAPIKey(forApp appId: String) -> Bool {
        return false
    }
}

More information

To learn how to use map-related JSAPIs in your mini program, check the following topics: