Aigens SDK enable native IOS/Android app to embed Aigens universal UX into the application.
- IOS - Swift 4.2+ , IOS 12+
- Android - API Level 28+, Android 9+
AigensSdkCore is available through CocoaPods. To install it, simply add the following line to your Podfile:
Initialize pod file, if not already enabled:
pod init
Add AigensSdkCore into Podfile:
pod 'AigensSdkCore', '0.1.0'
# If have applepay
pod 'AigensSdkApplepay', '0.0.8'
Run pod install to download the dependency.
pod install
Add permissions required in "Info.plist" depending on features.
#GPS Feature
- NSLocationAlwaysUsageDescription (Privacy - Location Always Usage Description)
- NSLocationWhenInUseUsageDescription (Privacy - Location When In Use Usage Description)
#Camera Feature
- NSCameraUsageDescription (Privacy - Camera Usage Description)
- NSPhotoLibraryAddUsageDescription (Privacy - Photo Library Additions Usage Description)
- NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)
#Calendar
- NSCalendarsUsageDescription
# add schemes in info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixinULAPI</string>
<string>weixin</string>
<string>octopus</string>
<string>wechat</string>
<string>hsbcpaymepay</string>
<string>alipay</string>
<string>alipays</string>
<string>alipayhk</string>
<string>mpay</string>
</array>
Make sure jcenter() is part of reporsitory in the "settings.gradle" config. Newer Android projects might not automatically include this repository.
repositories {
google()
mavenCentral()
jcenter()
}
Include the aigens-sdk-core dependency in "build.gradle".
dependencies {
implementation 'com.aigens:aigens-sdk-core:0.1.0'
# If have googlepay
implementation 'com.aigens:aigens-sdk-googlepay:0.0.6'
}
Include the actvity in "AndroidManifest.xml".
Add permissions required in "AndroidManifest.xml" depending on features.
<manifest>
<application>
<activity
android:name="com.aigens.sdk.WebContainerActivity"
android:screenOrientation="portrait"
android:exported="true"
android:launchMode="singleTask"
>
<!-- 1. android:autoVerify="true" -->
<!-- 2. <data android:scheme="https" /> -->
<!-- 3. <data android:host="domain.name" android:pathPrefix="/toapp" /> -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="domain.name" android:pathPrefix="/toapp" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.walletapi.enabled"
android:value="true" />
</application>
<queries>
<package android:name="com.tencent.mm" />
<package android:name="com.octopuscards.nfc_reader" />
<package android:name="hk.com.hsbc.paymefromhsbc" />
<package android:name="com.macaupass.rechargeEasy" />
<package android:name="hk.alipay.wallet" />
<package android:name="com.eg.android.AlipayGphone" />
</queries>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- calendar -->
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission android:name="android.permission.READ_CALENDAR"/>
</manifest>
Sample Project: https://github.com/AigensTechnology/AigensSdkDemo
The SDK open a URL for the web UI. The URL can be a predefined URL or scan from an QR code. Developer can use a scanner to obtain the URL and use the following code to open the UI within native app.
- AppDelegate.m
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"CapacitorOpenURLNotification" object:[NSDictionary dictionaryWithObject: url forKey:@"url"]];
return YES;
}
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType {
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
[[NSNotificationCenter defaultCenter] postNotificationName:@"CapacitorOpenUniversalLinkNotification" object:[NSDictionary dictionaryWithObject: userActivity.webpageURL forKey:@"url"]];
return YES;
}
- AppDelegate.swift
import Capacitor
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
func application(_ application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool {
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
}
}
import UIKit
import Foundation
import aigens_sdk_core
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func openClicked(_ sender: Any) {
let url = "https://scantest.aigens.com/scan?code=c3RvcmU9NTAwJnNwb3Q9MSZwYWdlPWJ5b2Q="
let bridgeVC = WebContainerViewController()
var options = [String: Any]()
options["url"] = url
let member:Dictionary<String, Any> = [
"memberCode" : "<crmMemberId>",
"source" : "<merchant>",
"sessionId" : "<sessionId>",
"pushId": "<applePushToken>",
"deviceId": "<deviceId>",
"universalLink": "<start with https://xxxx>",
"appleMerchantId": "<YourAppleMerchantId>",
"language": "en" // en/zh,
"isGuest": false // true/false
]
let deeplink:Dictionary<String, Any> = [
"addItemId" : "<itemId>",
"addDiscountCode" : "<discountCode>",
"addOfferId" : "<offerId>"
]
options["member"] = member
options["deeplink"] = deeplink
options["debug"] = isUat ? true : false;
bridgeVC.options = options
bridgeVC.modalPresentationStyle = .fullScreen
self.present(bridgeVC, animated: true)
}
}
Sample Project: https://github.com/AigensTechnology/AigensSdkDemo
import com.aigens.sdk.WebContainerActivity;
//...
private void openUrl(){
Activity activity = this;
Intent intent = new Intent(activity, WebContainerActivity.class);
String url = "https://scantest.aigens.com/scan?code=c3RvcmU9NTAwJnNwb3Q9MSZwYWdlPWJ5b2Q=";
intent.putExtra("url", url);
Map<String, String> member = new HashMap<String, String>();
member.put("memberCode", "<crmMemberId>");
member.put("source", "<merchant>");
member.put("sessionId", "<sessionId>");
member.put("pushId", "<googlePushToken>");
member.put("deviceId", "<deviceId>");
member.put("language", "en");
member.put("isGuest", false); // true/false
// from : <data android:scheme="https" />
// <data android:host="domain.name" android:pathPrefix="/toapp" />
member.put("universalLink", "https://xxx.xx.com/toapp");
Map<String, String> deeplink = new HashMap<String, String>();
deeplink.put("addItemId", "<itemId>");
deeplink.put("addDiscountCode", "<discountCode>");
deeplink.put("addOfferId", "<offerId>");
intent.putExtra("member", (Serializable) member);
intent.putExtra("deeplink", (Serializable) deeplink);
intent.putExtra("debug", isUat ? true : false);
intent.putExtra("ENVIRONMENT_PRODUCTION", true);
// intent.putExtra("ENVIRONMENT_PRODUCTION", false);
activity.startActivity(intent);
}
Optionally, pass a member object to automatucally login the customer.
Member Data:
- memberCode - The unique identifier of the member in CRM backend
- source - A merchant brand name string to indicate which brand the member belongs to
- sessionId - Member's current session key for CRM access
- pushId - Provide the push token registered with Google's push service. You can set pushId without other member detail for anonymous user.
- deviceId - Each device is unique, each device is the same value.
- universalLink - Use it to return to the app
- appleMerchantId - If you has applepay need to set.
- language - en/zh
Deeplink Data:
- addItemId - Item to be added when user navigate to order page.
- addDiscountCode - Discount code to be added automatically.
- addOfferId - Apply the offer that belong to the user when user checkout.
ENVIRONMENT_PRODUCTION
- default: true, set environment for google pay
TBA
Aigens Technology Limited
Contact the corresponding project manager for additional support.
Aigens SDK is available for merchants with an active subscription.