Cordova Ionic PhoneGap SDK

Cordova Ionic PhoneGap SDK

Installlink

Install - JSlink

plugin addlink

cordova plugin add airbridge-cordova-sdk

requirelink

When Ionic Project,
Please add following code into the .ts files which need to use Airbridge SDK.

import ...
...
declare let Airbridge: any;
...

Install - Androidlink

  • The modules below will be installed automatically.
    • io.airbridge:sdk-android
    • com.android.installreferrer:installreferrer
    • com.google.code.findbugs:jsr305
  • The privileges below will be added automatically.
    • android.permission.INTERNET
    • android.permission.ACCESS_NETWORK_STATE

Proguardlink

If you are using Proguard check the following information.
Add the following text to the 'android/app/proguard-rules.pro' file:

-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient {public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$newBuilder { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$Builder { public *;}
-keep class com.android.installreferrer.api.ReferrerDetails {public *;}
-keep class com.android.installreferrer.api.InstallReferrerStateListener {public *;}
-keep class io.airbridge.deviceinfo.** { *; }
-keepclassmembers class io.airbridge.** { public *; }
-keep public class io.airbridge.**

MainApplication.javalink

  1. Add file platforms/android/app/src/main/java/.../MainApplication.java.

  2. Please add the following code.

package ...;
import android.app.Application;
import co.ab180.airbridge.cordova.AirbridgeCO;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AirbridgeCO.init(this, "YOUR_APP_NAME", "YOUR_APP_TOKEN");
}
}

'App name' can be found on the dashboard at 'App Setting > App Info'.
App token' can be found on the dashboard at 'App Setting > Tokens Management'.

AndroidManifest.xmllink

In platforms/android/app/src/main/AndroidManifest.xml add the following attribute to the application tag.

<application ...
+ android:name=".MainApplication"
...>
...
</application>

Install - iOSlink

AppDelegate.mlink

Add the following code to the import section of the file ios/[Project Name]/AppDelegate.m.

#import "AirbridgeCO.h"

Add the following code to the function application:idFinishLaunchingWithOptions: in the file ios/[Project Name]/AppDelegate.m.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AirbridgeCO getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
...
}

'App name' can be found on the dashboard at 'App Setting > App Info'.
App token' can be found on the dashboard at 'App Setting > Tokens Management'.

Register the information in your app to the Airbridge dashboard to use the Deeplink feature.
On the Airbridge dashboard, click the Deeplinks menu in the sidebar and you will see the screen as shown below.

deeplinks en

Schemelink

  1. Enter the desired scheme in the Android URL scheme area of the Deeplink registration part picture by attaching "://"

example) scheme://

  1. Prepare the signing key you used when signing up for the Google Play Store.

  2. Run the following code.

keytool -list -v -keystore my-release-key.keystore
  1. Copy the SHA256 column of the certificate fingerprints and Enter Android sha256_cert_fingerprints area of the deeplink registration part.

ex) 14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5

Schemelink

  1. Enter the desired scheme in the iOS URI scheme area of the Deeplink registration part picture by attaching "://"

example) scheme://

  1. Connect to the link below.

  2. Click the app name of the project.

  3. Copy the string in the Prefix and ID area of the picture below and enter the string Prefix + "." + ID in the iOS App ID area of the picture in the part.

Example) 9JA89QQLNQ.com.apple.wwdc

ios app id

Set up the app to use deeplink.

setDeeplinkListenerlink

Register a callback called when Deeplink or Deferred Deeplink occurs.

// www/js/index.js
var app = {
...
onDeviceReady: function() {
...
Airbridge.deeplink.setDeeplinkListener((deeplink) => {
// Code to be executed when a `Deeplink` or `Deferred Deeplink` occurs
// deeplink = https://appname.airbridge.io/...
console.log(deeplink);
});
...
}
...
}

setDeferredDeeplinkListener (Option)link

Register a callback called when Deferred Deeplink occurs.

// www/js/index.js
var app = {
...
onDeviceReady: function() {
...
Airbridge.deeplink.setDeferredDeeplinkListener((deeplink) => {
// Code to be executed when a `Deferred Deeplink` occurs
// deeplink = https://appname.airbridge.io/...
console.log(deeplink);
});
...
}
...
}

AndroidManifest.xmllink

In the MainActivity area of the file android/app/src/main/AndroidManifest.xml, insert the intent-filter as shown below.

<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="http" android:host="YOUR_APP_NAME.deeplink.page" />
<data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
</intent-filter>
<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="http" android:host="YOUR_APP_NAME.airbridge.io" />
<data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="EXAMPLE_SCHEME" />
</intent-filter>

Enter the app name to YOUR_APP_NAME
Enter the scheme value set in the dashboard to EXAMPLE_SCHEME

MainActivity.javalink

Insert the following code in the file android/app/src/main/java/.../MainActivity.java.

@Override
protected void onResume() {
super.onResume();
AirbridgeCO.getDeeplink().fetch(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}

Xcodelink

Schemelink

  1. Xcode > Project file > Info > URL Types.
  2. Put scheme value set in the dashboard to identifier and URL Schemes.

ios url scheme

Remove the :// and insert it.

  1. Xcode > Project File > Signing & Capabilities > Associated Domains.
  2. Click + button and add applinks:YOUR_APP_NAME.airbridge.io.
  3. Click + button and add applinks:YOUR_APP_NAME.deeplink.page.

'YOUR_APP_NAME' can be found on the dashboard at 'App Setting > App Info'.

AppDelegate.mlink

Schemelink

  1. Open ios/[Project Name]/AppDelegate.m file.
  2. Insert below code.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
{
NSLog(@"openURL : %@", url);
[AirbridgeCO.deeplink handleURLSchemeDeeplink:url
withSourceBundle:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
return YES;
}
  1. If you are targeting iOS 8.x or earlier, insert the following additional code.
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation
{
NSLog(@"openURL : %@", url);
[AirbridgeCO.deeplink handleURLSchemeDeeplink:url
withSourceBundle:sourceApplication];
return YES;
}
  1. Open ios/[Project Name]/AppDelegate.m file.
  2. Insert below code.
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray* _Nullable))restorationHandler
{
NSLog(@"continueUserActivity : %@", url);
[AirbridgeCO.deeplink handleUniversalLink:userActivity.webpageURL];
return YES;
}

Verify Installation Completionlink

  1. Delete the app from the test device.
  2. Reinstall the app and run the app on the same test device.
  3. Press on Realtime Log under Airbridge Dashboard → Select Apps → Log Data.
  4. Press Mobile SDK Log and enter Android GAID or iOS IDFA in Device UUID..
  • If device UUID (Android GAID or iOS IDFA) exposure is not confirmed, please re-check that it is installed as directed in install.
  • Log exposure can be delayed by up to 5 minutes.
  • Confirm Android GAID: 'Setup' → Google Setup → Advertise → 'Check My Advertisement ID' is the value of Android GAID.

In app eventlink

You can measure various user journey events through the Android SDK.

There are 9 basic events related to users' information and e-commerce user journeys. Custom events can be additionally defined as well.

Information that is attached to all events can be additionally added.
You would be able to track and analyze more accurate statistics if you include more event information.

EventOption objectlink

All events in Airbridge can be specified through EventOption.

NameTypeOptionalDescription
actionstringOptionalEvent subclass 1
labelstringOptionalEvent subclass 2
valuestringOptionalEvent custom value
attributesObjectOptionalEvent custom information

About action, label, check in-app event classification part.

In-app event - Userlink

User in-app events are a component of 'Cross Platform User Matching'.
If possible, please send more than one type of user information.

When sign-up or sign-in event occurs,
until the next sign-out event occurs, all events are recorded as being triggered by that user.

When sign-out event occurs,
all events until the next sign-in event are recorded without that user-related data.

All user information is sent by default in a hashed format (SHA256).

User objectlink

Object that has product information.

NameTypeOptionalDescription
IDstringOptionalUser ID
emailstringOptionalUser email
phonestringOptionalUser cell-phone-number

Sign uplink

When a user sign-up, call signUp.

signUplink

  1. Send sign-up event.
  2. Setting up users that will be applied to the next events.
Parameter :
NameTypeOptionalDescription
userUserOptionalUser information
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.signUp({
ID: 'test',
email: 'test@ab180.co',
phone: '000-0000-0000',
});

Sign Inlink

When a user sign-in, call signIn.

signInlink

  1. Send sign-in event.
  2. Setting up users that will be applied to the next events.
Parameter :
NameTypeOptionalDescription
userUserOptionalUser information
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.signIn({
ID: 'test',
email: 'test@ab180.co',
phone: '000-0000-0000',
});

Sign Outlink

If the user signs out, call signOut.

signOutlink

  1. Send sign-out event.
  2. Remove users that will be applied to the next events.b

Example codelink

Airbridge.event.signOut();

In-app events - Commercelink

Track the user's commerce-related behavior.

Product objectlink

Object that has product information.

NameTypeOptionalDescription
IDstringOptionalProduct unique ID
namestringOptionalProduct name
currencystringOptionalCurrency
According toISO 4217 standard
pricenumberOptionalProduct price
quantitynumberOptionalProduct quantity
positionnumberOptionalPosition of the products on the list

Home screen lookuplink

When the user navigates to the app's home screen, call viewHome.

viewHomelink

Send home-screen-lookup event.

Example codelink

Airbridge.event.viewHome();

Product list lookuplink

When the user views the product list, call viewProductList.

viewProductListlink

Send product-list-lookup event.

Parameter :link

NameTypeOptionalDescription
listIDstringOptionalUnique ID for a product list
productsArray.<Product>OptionalProduct list
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.viewProductList({
listID: 'ID-1234567890',
products: [
{
name: 'product A',
},
{
name: 'product B',
},
]
});
  • When users scroll through the list and load new information
    Additional loaded product information, it is recommended that create new event and send it separately.

Search results lookuplink

When the user searches for a product, call viewSearchResult.

viewSearchResultlink

Send search-results-lookup event.

Parameter :link

NameTypeOptionalDescription
querystringOptionalSearch term
productsArray.<Product>OptionalProduct list of the search result
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.viewSearchResult({
query: 'product A',
products: [
{
name: 'product A AAA',
},
{
name: 'product A BBB',
},
],
});

Product details lookuplink

When user views the details of the product, call viewProductDetail.

viewProductDetaillink

Send product-details-lookup event.

Parameter :link

NameTypeOptionalDescription
productsArray.<Product>OptionalProduct list of lookup
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.viewProductDetail({
products: [
{
name: 'product A',
},
],
});

Add to shopping cartlink

When user adds the product in the cart, call addToCart.

addToCartlink

Send add-to-shopping-cart event.

Parameter :link

NameTypeOptionalDescription
cartIDstringOptionalUnique ID of shopping cart
productsArray.<Product>OptionalProduct list of shopping cart
currencystringOptionalCurrency
According to ISO 4217 standard
totalnumberOptionalTotal price of products
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.addToCart({
cartID: 'ID-1234567890',
products: [
{
name: 'product A',
},
],
currency: 'KRW',
total: 50000,
});

Purchaselink

When user purchase, call purchase.

purchaselink

Send purchase event.

Parameter :link

NameTypeOptionalDescription
transactionIDstringOptionalUnique ID of purchase
productsArray.<Product>OptionalProduct list of shopping cart
isInAppPurchasebooleanOptionalIs from in-app-purchase?
currencystringOptionalCurrency
According to ISO 4217 standard
totalnumberOptionalTotal price of products
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.purchase({
transactionID: 'transactionID-purchase',
products: [
{
name: 'product purchase A name',
ID: 'product purchase A ID',
price: 100,
quantity: 10,
},
],
isInAppPurchase: true,
currency: 'KRW',
total: 50000,
});

In-app Event - Customlink

Customize and use in-app event.

customlink

Send custom event.

Parameter :link

NameTypeOptionalDescription
categorystringRequiredEvent name
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.custom('Custom', {
action: 'Action custom',
label: 'Label custom',
value: 9999,
attributes: {
custom: 'value custom',
},
});

Settingslink

Set the behavior of the Airbridge SDK according to the developer's intention.

In-app event classificationlink

The Airbridge dashboard displays statistics by separating events according to Category, Action, and Label.

Category is a name that you choose as a way to group events that you want to analyze.
Action is used to define the subgroups for a particular event Category.
Label is used to further define the subgroups for a particular Action.

For all in-app events, you can modify Action and Label.

Example codelink

for(var i=0; i<10; i++) {
Airbridge.event.signUp({
ID: 'test'
}, {
action: 'Seoul',
label: '30s',
});
}
for(var i=0; i<20; i++) {
Airbridge.event.signUp({
ID: 'test'
}, {
action: 'Seoul',
label: '40s',
});
}
for(var i=0; i<15; i++) {
Airbridge.event.signUp({
ID: 'test'
}, {
action: 'Busan',
label: '30s',
});
}
for(var i=0; i<8; i++) {
Airbridge.event.purchase({
transactionID: 'ID-1234567890',
}, {
action: 'Product A',
label: 'Option B',
});
}
for(var i=0; i<7; i++) {
Airbridge.event.purchase({
transactionID: 'ID-1234567890',
}, {
action: 'Product A',
label: 'Option C',
});
}
for(var i=0; i<10; i++) {
Airbridge.event.custom('Subscription', {
action: 'Normal',
});
}
for(var i=0; i<5; i++) {
Airbridge.event.custom('Subscription', {
action: 'Premium',
});
}

You can view statistics for the count of each event based on Category in the Airbridge dashboard.
You can view statistics by separating the events in the same Category with the action and then separating the events through the label.

As a result, you can get the following results on the dashboard.

CategoryActionLabelCount
Sign upSeoul30s10
Sign upSeoul40s20
Sign upBusan30s15
PurchaseProduct AOption B8
PurchaseProduct AOption C7
SubscriptionNormal10
SubscriptionPremium5

Session durationlink

The default value of session duration in Airbridge is 5 minutes.

You can set the session period by calling the code below.

    ...
    [AirbridgeCO setSessionTimeout:(1000 * 60 * 5)];
    [AirbridgeCO getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
    ...

    The session period is in milliseconds. The maximum value is 604800000 (7 days).

    Both Android and iOS should be set before initialization.

    Disable hashing of user informationlink

    All information about the user is by default sent in a hashed format (SHA256).

    If you do not want to hash the information, you can use the method below to change the settings.

      ...
      // Disable user information hash
      [AirbridgeCO setIsUserInfoHashed:NO];
      [AirbridgeCO getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
      ...

      Both Android and iOS should be set before initialization.

      Stop tracking (Opt-out)link

      You can stop sending events from the SDK.

      ...
      // Stop tracking
      [AirbridgeCO setIsTrackingEnabled:NO];
      [AirbridgeCO getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
      ...

      true : Tracking
      false : Stop Tracking

      Both Android and iOS should be set before initialization.

      Additional Collectionlink

      You can gather more additional information.

      User carrier name collection (Android)link

      You can collect the name of the android user's carrier.

      Add the following permissions to the android/app/src/main/AndroidManifest.xml file.

      ...
      <uses-permission android:name="android.permission.READ_PHONE_STATE" />
      ...

      This setting increases the accuracy of cross-platform user matching.

      You can use the code below to perform deeplink actions on the App and track the behavior.

      Airbridge.placement.click('https://abr.ge/~~~', 'ablog://main', 'https://airbridge.io');
      Airbridge.placement.impression('https://abr.ge/~~~');

      clicklink

      click function +1 click statistic for the tracking link and moves to the set App, Web, or Fallback.
      When the tracking link is clicked, call click function.

      In click function, deeplink and fallback are backup links used when there is no Internet connection.
      (All of these are optional parameters.)
      Deeplink parameters are only available in Custom URL Scheme format.

      Impressionlink

      impression function +1 impression statistic for the 'tracking link'.
      When the tracking link is displayed on the UI, call impression function.

      If you are using custom domain, you cannot use tracking link using custom short ID.
      example: http://deeplink.ab180.co/custom -> Unavailable
      example: http://deeplink.ab180.co/a3b1c2 -> Available
      example: https://abr.ge/a3b1c2 -> Available

      Advancedlink

      Manual setting for user informationlink

      Even without sign-up, sign-in and sign-out events, you can still set the user information manually.

      When user information is set manually, until next setting or using the function signIn, signUp, and signOut. all events are recorded as being triggered by the user.

      setUserlink

      Change the current user.

      Parameter :link

      NameTypeOptionalDescription
      userUserOptionalUser information

      Replace the current user with the user entered.

      updateUserlink

      Modify the current user information.

      Parameter :link

      NameTypeOptionalDescription
      userUserOptionalUser information

      If the user entered has no ID value, the ID of the current user is not modified. If the user entered has an ID value, modify the ID of the current user.

      Example codelink

      Airbridge.state.setUser({
      ID: 'test1',
      email: 'test1@ab180.co',
      });
      Airbridge.state.setUser({
      email: 'test2@ab180.co',
      phone: '222-2222-2222',
      });
      Airbridge.state.updateUser({
      ID: 'test3',
      });

      The code above works as follows.

      User = { ID: 'test1', email: 'test1@ab180.co' }
      -> User = { email: 'test1@ab180.co', phone: '222-2222-2222' }
      -> User = { ID: 'test3', email: 'test2@ab180.co', phone: '222-2222-2222' }

      Referencelink

      Document

      업데이트link

      If you are updating the SDK from a previous version, please check below.

      1.0.X -> 1.1.Xlink

      Installlink

      Uninstall the old version of SDK.

      cordova plugin remove airbridge-cordova-sdk

      Install the new version of SDK.

      cordova plugin add airbridge-cordova-sdk

      Javascriptlink

      DeeplinkListener

      Remove the getInitialDeeplink function and use the setDeeplinkListener function only.

      - Airbridge.deeplink.getInitialDeeplink().then((deeplink) => {
      -
      - });
      .
      . Airbridge.deeplink.setDeeplinkListner((deeplink) => {
      .
      . });

      Androidlink

      AndroidManifest.xml

      In the MainActivity area of the file android/app/src/main/AndroidManifest.xml, insert the intent-filter as shown below.

      + <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="http" android:host="YOUR_APP_NAME.deeplink.page" />
      + <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
      + </intent-filter>
      . <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="http" android:host="YOUR_APP_NAME.airbridge.io" />
      . <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
      . </intent-filter>
      . <intent-filter>
      . <action android:name="android.intent.action.VIEW" />
      .
      . <category android:name="android.intent.category.DEFAULT" />
      . <category android:name="android.intent.category.BROWSABLE" />
      .
      . <data android:scheme="EXAMPLE_SCHEME" />
      . </intent-filter>
      MainActivity.java

      Modify android/app/src/main/java/.../MainActivity.java.

      . import co.ab180.airbridge.cordova.AirbridgeCO;
      .
      . public class MainActivity extends ReactActivity {
      + @Override
      + protected void onResume() {
      + super.onResume();
      +
      + AirbridgeCO.getDeeplink().fetch(getIntent());
      + }
      +
      . @Override
      . public void onNewIntent(Intent intent) {
      . super.onNewIntent(intent);
      . setIntent(intent);
      . }
      . }

      iOSlink

      Xcode

      Universal Link

      1. Xcode > Project File > Signing & Capabilities > Associated Domains.
      2. Click + button and add applinks:YOUR_APP_NAME.deeplink.page.

      'YOUR_APP_NAME' can be found on the dashboard at 'App Setting > App Info'.

      AppDelegate.m

      Modify ios/.../AppDelegate.m.

      . - (BOOL)application:(UIApplication *)application
      . openURL:(NSURL *)url
      . options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
      . {
      - [AirbridgeCO.instance handleURLSchemeDeeplink:url
      - withSourceBundle:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
      + [AirbridgeCO.deeplink handleURLSchemeDeeplink:url
      + withSourceBundle:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
      .
      . return YES;
      . }
      .
      . - (BOOL)application:(UIApplication*)application
      . openURL:(NSURL*)url
      . sourceApplication:(NSString*)sourceApplication
      . annotation:(id)annotation
      . {
      - [AirbridgeCO.instance handleURLSchemeDeeplink:url
      - withSourceBundle:sourceApplication];
      + [AirbridgeCO.deeplink handleURLSchemeDeeplink:url
      + withSourceBundle:sourceApplication];
      .
      . return YES;
      . }

      If you are targeting iOS 8.x or earlier, modify the following additional code.

      . - (BOOL)application:(UIApplication*)application
      . continueUserActivity:(NSUserActivity*)userActivity
      . restorationHandler:(void (^)(NSArray* _Nullable))restorationHandler
      . {
      - [AirbridgeCO.instance handleUniversalDeeplink:userActivity.webpageURL];
      + [AirbridgeCO.deeplink handleUniversalLink:userActivity.webpageURL];
      .
      . return YES;
      . }