iOS SDK

iOS SDK

Accept IDFA Terms and Conditionslink

Please agree to *IDFA Terms and Conditions** before submitting the app to the App Store.

  1. Check the 'Yes' item.
  2. The screen as shown below will be displayed.
  3. Check the 'Attribute this app Install to a previously served advertisement' item.
  4. Check the 'Attribute an action taken within this app to a previously served advertisement' item.
  5. Check the 'Limit Ad Tracking Setting in iOS' item.

ios idfa agreement

Installlink

1. Cocoapodslink

  1. Create Podfile file with the command shown below.
cd path/to/project
touch Podfile
  1. Please fill in the contents of the Podfile file as shown below.
target '[Project Name]' do
pod 'AirBridge'
end
  1. Open terminal and enter the following command.
cd path/to/project
pod install

If there are 'pod' commands, install cocoapods.

sudo gem install cocoapods

If Cocoapods is not available, check this part Advanced - Direct Install of SDK.

2. Swift Bridge Headerlink

If you are using Swift, follow the steps below.

  1. Click on [File > New > File...] > iOS - Source > Header File.
  2. Save as <YOUR_PROJECT_NAME>-Bridging-Header.h.
  3. Add #import <AirBridge/AirBridge.h> to the header file.
  4. Add /PATH/TO/<YOUR_PROJECT_NAME>-Bridging-Header.h in the Objective-C Bridging Header property of Build Settings.

3. AppDelegate.hlink

Add the following code to the import section of the file AppDelegate.h.

#import <AirBridge/AirBridge.h>

For Swift project, add it to the file <YOUR_PROJECT_NAME>-Bridging-Header.h.

4. AppDelegate.mlink

Add the following code to the method application:didFinishLaunchingWithOptions: in the file AppDelegate.m.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
[AirBridge 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'.

If you are using Swift, please add it to the AppDelegate.swift file.

Register the informations in your app to the Airbridge dashboard to use the Deeplink feature.
On the Airbridge dashboard, click on the Deeplinks button on the sidebar and you will see the screen below.

deeplinks en

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

  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'.

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. 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);
[AirBridge.deeplink handleUniversalLink:userActivity.webpageURL];
return YES;
}

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);
[AirBridge.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);
[AirBridge.deeplink handleURLSchemeDeeplink:url
withSourceBundle:sourceApplication];
return YES;
}
  1. Open ios/[Project Name]/AppDelegate.m file.
  2. Insert below code.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
[AirBridge getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
[AirBridge.deeplink setDeeplinkCallback:^(NSString* deeplink) {
// code to operate when deeplink
// deeplink = https://appname.airbridge.io/...
NSLog(@"DeeplinkCallback : %@", deeplink);
}];
}

If you have set up a custom domain of tracking link, set it as follows.

  1. Open info.plist.
  2. Add the following value.
KeyTypeValue
co.ab180.airbridge.trackingLink.customDomainsArray(1 item)
- Item 0Stringexample.com

ios trackinglink custom domain

Insert the custom domain you set to example.com section.

You can change the shape of the deeplink that occurs on the DeeplinkCallback.

  1. Open info.plist.
  2. Add the following value.
KeyTypeValue
co.ab180.airbridge.deeplink.schemeStringexample
co.ab180.airbridge.deeplink.hostStringexample.com

ios deeplink custom domain

If set as above, deeplink of DeeplinkCallback turn
https://appname.airbridge.io/... into
example://example.com/...

Deepink - Custom Domain and Tracking Link - Custom Domain must not be the same.

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. Click on 'Realtime Log' under Airbridge Dashboard → Select Apps → Log Data.
  4. Enter iOS IDFA in 'Device UUID..'.
  • If device UUID (iOS IDFA) exposure is not confirmed, re-check that the SDK is installed as directed in Install.
  • Log exposure can be delayed by up to 5 minutes.

In-app Eventlink

You can measure various user journey events through the Airbridge iOS 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.

All basic event's parameters can be added optionally.

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 in hash (SHA256).

ABUser Classlink

This class contains user information.

Constructorlink

NameParameterDescription
init-Create a blank ABUser object

Propertylink

NameTypeDescription
IDNSStringUser ID
emailNSStringUser email
phoneNSStringUser cell-phone-number
attributesNSDictionary<NSString, NSObject>User attributes
aliasNSDictionary<NSString, NSString>User alias

The number of User Attributes is up to 100.
User Attributes' key length is up to 128.
The value of User Attributes must be NSNumber or NSString.
If the value of User Attributes is NSString, the length is up to 1024.
The User Attributes' key must satisfy the regular expression ^[a-z][a-z0-9_]*$.

The number of User Alias is up to 10.
User Alias key length is up to 128.
User Alias value length is up to 128.
The User Alias key must satisfy the regular expression ^[a-z_][a-z0-9_]*$.

ABUserEvent Classlink

Class for sending user events.

Constructorlink

NameParameterDescription
init-Create an ABUserEvent object that is empty
initWithUserABUser* user
User information to be used to send events
Create ABUserEvent object with user information

Methodlink

NameParameterDescription
sendSignup-Send sign-up events
sendSignin-Send sign-in Event
expireUser-Send sign-out Events

Sign uplink

When a user signs up, create an ABUserEvent object and execute sendSignup function.

Example codelink

#import <AirBridge/ABUser.h>
#import <AirBridge/ABUserEvent.h>
ABUser* user = [[ABUser alloc] init];
user.ID = @"testID";
user.email = @"testID@ab180.co";
user.phone = @"000-0000-0000";
user.attributes = @{
@"one": @"value",
@"two": @2
};
ABUserEvent* event = [[ABUserEvent alloc] initWithUser:user];
[event sendSignup];

Sign inlink

When a user signs in, create ABUserEvent object and execute sendSignin function.

Example codelink

#import <AirBridge/ABUser.h>
#import <AirBridge/ABUserEvent.h>
ABUser* user = [[ABUser alloc] init];
user.ID = @"testID";
user.email = @"testID@ab180.co";
user.phone = @"000-0000-0000";
user.attributes = @{
@"one": @"value",
@"two": @2
};
ABUserEvent* event = [[ABUserEvent alloc] initWithUser:user];
[event sendSignin];

Sign outlink

When a user signs out, create an ABUserEvent object and execute expireUser function.

Example codelink

#import <AirBridge/ABUserEvent.h>
ABUserEvent* event = [[ABUserEvent alloc] init];
[event expireUser];

In-App Event - Commercelink

Track the user's commerce-related behavior.

ABProduct Classlink

This class contains product information.

constructorlink

NameParameterDescription
init-Create a blank ABUser object

Propertylink

NameTypeDescription
idxNSString*Unique ID
nameNSString*Product name
priceNSNumber*Price of products
currencyNSString*Product currency
according to ISO 4217 standard
orderPositionNSNumber*Position of the products on the list
quantityNSNumber*Quantity of products

ABEcommerceEvent Classlink

Class for sending commerce events.

constructorlink

NameParameterDescription
init-Create a blank
ABEmerceEvent object
initWithProductsNSArray<ABProduct>* products
a list of products
Create an ABEmerceEvent object
with a list of products

Propertylink

NameTypeDescription
productsNSArray*List of products
productListIDNSString*Unique ID of product list
queryNSString*Search term
cartIDNSString*Unique ID of shopping cart
transactionIDNSString*Unique ID of purchase
eventValueNSNumber*Total price of product list
currencyNSString*Currency
According toISO 4217 standard
isInAppPurchaseBOOLIs from in-app-purchase?

Methodlink

NameParameterDescription
sendViewHome-Send home-screen-lookup-event
sendViewProductList-Send product-list-lookup-event
sendViewSearchResult-Send search-result-lookup-event
sendViewProductDetail-Send product-details-page-lookup-event
sendAddProductToCart-Send add-to-shopping-cart-event
sendCompleteOrder-Send purchase-event

Home screen lookuplink

When the user navigates to the app's home screen
create the ABEcommerceEvent object and execute the sendViewHome function.

Example codelink

#import <AirBridge/ABEcommerceEvent.h>
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] init];
[event sendViewHome];

Product list lookuplink

When the user lookup the product list
create an object named ABEcommerceEvent and execute the sendViewProductList function.

Example codelink

#import <AirBridge/ABProduct.h>
#import <AirBridge/ABEcommerceEvent.h>
ABProduct* product1 = [[ABProduct alloc] init];
product1.idx = @"idx1";
product1.name = @"name1";
product1.price = @100;
product1.currency = @"USD";
product1.orderPosition = @1;
ABProduct* product2 = [[ABProduct alloc] init];
product2.idx = @"idx2";
product2.name = @"name2";
product2.price = @200;
product2.currency = @"USD";
product2.orderPosition = @2;
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] initWithProducts:@[product1, product2]];
event.productListID = @"listID";
[event sendViewProductList];
  • 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
create an object named ABEcommerceEvent and execute the sendViewSearchResult function.

Example codelink

#import <AirBridge/ABProduct.h>
#import <AirBridge/ABEcommerceEvent.h>
ABProduct* product1 = [[ABProduct alloc] init];
product1.idx = @"idx1";
product1.name = @"name1";
product1.price = @100;
product1.currency = @"USD";
product1.orderPosition = @1;
ABProduct* product2 = [[ABProduct alloc] init];
product2.idx = @"idx2";
product2.name = @"name2";
product2.price = @200;
product2.currency = @"USD";
product2.orderPosition = @2;
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] initWithProducts:@[product1, product2]];
event.query = @"query";
[event sendViewSearchResult];

Product details lookuplink

When user lookup the details of the product
create the ABEcommerceEvent object and execute the sendViewProductDetail function.

Example codelink

#import <AirBridge/ABProduct.h>
#import <AirBridge/ABEcommerceEvent.h>
ABProduct* product1 = [[ABProduct alloc] init];
product1.idx = @"idx1";
product1.name = @"name1";
product1.price = @100;
product1.currency = @"USD";
product1.orderPosition = @1;
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] initWithProducts:@[product1]];
[event sendViewProductDetail];

Add to shopping cartlink

When user adds the item in the cart
create the ABEcommerceEvent object and execute the sendAddProductToCart function.

Example codelink

#import <AirBridge/ABProduct.h>
#import <AirBridge/ABEcommerceEvent.h>
ABProduct* product1 = [[ABProduct alloc] init];
product1.idx = @"idx1";
product1.name = @"name1";
product1.price = @100;
product1.currency = @"USD";
product1.orderPosition = @1;
ABProduct* product2 = [[ABProduct alloc] init];
product2.idx = @"idx2";
product2.name = @"name2";
product2.price = @200;
product2.currency = @"USD";
product2.orderPosition = @2;
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] initWithProducts:@[product1, product2]];
event.cartID = @"cartID";
event.currency = @"KRW";
event.eventValue = @300;
[event sendAddProductToCart];

Purchaselink

When the user purchase
create the ABEcommerceEvent object and execute the sendCompleteOrder function.

Example codelink

#import <AirBridge/ABProduct.h>
#import <AirBridge/ABEcommerceEvent.h>
ABProduct* product1 = [[ABProduct alloc] init];
product1.idx = @"idx1";
product1.name = @"name1";
product1.price = @100;
product1.currency = @"USD";
product1.orderPosition = @1;
ABProduct* product2 = [[ABProduct alloc] init];
product2.idx = @"idx2";
product2.name = @"name2";
product2.price = @200;
product2.currency = @"USD";
product2.orderPosition = @2;
ABEcommerceEvent* event = [[ABEcommerceEvent alloc] initWithProducts:@[product1, product2]];
event.isInAppPurchase = YES;
event.eventValue = @300;
event.transactionID = @"transactionID";
event.currency = @"KRW";
[event sendCompleteOrder];

In-app Event - Customlink

Customize in-app events.

ABInAppEvent Classlink

Methodlink

NameparameterDescription
setCategoryNSString* category
event name
Set event's name
setActionNSString* action
event subclass 1
Set event's subclass 1
setLabelNSString* category
event subclass 2
Set event's subclass 2
setValueNSNumber* value
event custom value
Set event's custom value
setCustomsNSDictionary* value
event custom information
Set event's custom information
sendSend event

For Category, Action, and Label, see the topic In-app event classification.

Code examplelink

#import <AirBridge/ABInAppEvent.h>
ABInAppEvent* event = [[ABInAppEvent alloc] init];
[event setCategory:@"category"];
[event setAction:@"action"];
[event setLabel:@"label"];
[event setValue:@(123)];
[event setCustoms:@{@"key": @"value"}];
[event send];

Enter 'nil' for parameters not used.

Settingslink

Session durationlink

You can set the duration of the app's session by calling the following method before code 'AirBridge getInstance...'

The session duration is in milliseconds and must be at least 0 and 604800000 (7 days).

#import <AirBridge/AirBridge.h>
[AirBridge setSessionTimeout:1000 * 60 * 5];
[AirBridge getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];

The default value for the session duration is 1000 60 5 (5 minutes).

Disable hashing of user informationlink

All information about the user is 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.

#import <AirBridge/AirBridge.h>
// Disable user information hash
[AirBridge setIsUserInfoHashed:NO];
// Enable user information hash
[AirBridge setIsUserInfoHashed:YES];

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.
Custom in-app events' Category can be customized, and basic in-app events' cannot be customized.

Example codelink

#import <AirBridge/AirBridge.h>
ABUserEvent* userEvent1 = [[ABUserEvent alloc] init];
[userEvent1 setAction:@"Seoul"];
[userEvent1 setLabel:@"30s"];
ABUserEvent* userEvent2 = [[ABUserEvent alloc] init];
[userEvent2 setAction:@"Seoul"];
[userEvent2 setLabel:@"40s"];
ABUserEvent* userEvent3 = [[ABUserEvent alloc] init];
[userEvent3 setAction:@"Busan"];
[userEvent3 setLabel:@"30s"];
ABEcommerceEvent* ecommerceEvent1 = [[ABEcommerceEvent alloc] init];
[ecommerceEvent1 setAction:@"Product A"];
[ecommerceEvent1 setLabel:@"Option B"];
ABEcommerceEvent* ecommerceEvent2 = [[ABEcommerceEvent alloc] init];
[ecommerceEvent2 setAction:@"Product A"];
[ecommerceEvent2 setLabel:@"Option C"];
ABInAppEvent* customEvent1 = [[ABInAppEvent alloc] init];
[customEvent1 setCategory:@"Subscription"];
[customEvent1 setAction:@"Normal"];
ABInAppEvent* customEvent2 = [[ABInAppEvent alloc] init];
[customEvent2 setCategory:@"Subscription"];
[customEvent2 setAction:@"Premium"];
for(int i=0; i<10; i++) {
[userEvent1 sendSignup];
}
for(int i=0; i<20; i++) {
[userEvent2 sendSignup];
}
for(int i=0; i<15; i++) {
[userEvent3 sendSignup];
}
for(int i=0; i<8; i++) {
[ecommerceEvent1 sendCompleteOrder];
}
for(int i=0; i<7; i++) {
[ecommerceEvent2 sendCompleteOrder];
}
for(int i=0; i<10; i++) {
[customEvent1 send];
}
for(int i=0; i<5; i++) {
[customEvent2 send];
}

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 view the following results on the dashboard.

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

Additional Collectionlink

You can gather more additional information.

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

#import <AirBridge/AirBridge.h>
[AirBridge.placement click:@"https://abr.ge/~~~" deeplink:@"ablog://main" fallback:@"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

Advanced - Web Applink

When Web App case, You can send in-app events as follows.

Send event from native (option 1)link

On web, when iOS app, call native function and call Airbridge iOS SDK to send Mobile Event.
On web, when browser, call Airbridge Web SDK to send Web Event.

Example code - Javascriptlink

if (check iOS app) {
// When ios app, send event with Airbridge iOS SDK
webkit.messageHandlers.goal.postMessage({
'category': 'category',
'label': 'label',
'action': 'action',
'value': 123.0,
'customAttributes': {
'custom1': 123,
'custom2': 'abc'
}
});
} else {
// When web, send event with Airbridge Web SDK
airbridge.events.send('category', {
'label': 'label',
'action': 'action',
'value': 123.0,
'customAttributes': {
'custom1': 123,
'custom2': 'abc'
}
});
}

Example code - ViewControllerlink

@import WebKit;
#import <AirBridge/AirBridge.h>
#import "ViewController.h"
@interface ViewController () <WKUIDelegate, WKScriptMessageHandler>
@end
@implementation ViewController {
WKWebView* web;
}
- (void)loadView {
WKUserContentController* controller = [[WKUserContentController alloc] init];
[controller addScriptMessageHandler:self name:@"goal"];
WKWebViewConfiguration* conf = [[WKWebViewConfiguration alloc] init];
conf.userContentController = controller;
web = [[WKWebView alloc] initWithFrame:CGRectZero configuration:conf];
self.view = web;
}
- (void)viewDidLoad {
[super viewDidLoad];
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://~~~"]]];
}
- (void)userContentController:(WKUserContentController *)userContentController
didReceiveScriptMessage:(WKScriptMessage *)message
{
NSDictionary* body = message.body;
if([message.name isEqualToString:@"goal"]) {
[AirBridge.instance goalWithCategory:body[@"category"]
action:body[@"body"]
label:body[@"label"]
value:body[@"value"]
customAttributes:body[@"customAttributes"]];
}
}
@end

Send event from web (option 2)link

On web, when iOS app, init Airbridge iOS SDK with mobileApp to send Mobile Event.
On web, when browser, init Airbridge Web SDK to send Web Event.

Example code - Javascriptlink

(function(a_,i_,r_,_b,_r,_i,_d,_g,_e){if(!a_[_b]||!a_[_b].queue){_g=i_.getElementsByTagName(r_)[0];a_[_b]={queue:[]};_d={};for(_i=0;_i<_r.length;_d={$jscomp$loop$prop$m$2:_d.$jscomp$loop$prop$m$2},_i++)_d.$jscomp$loop$prop$m$2=_r[_i],~_d.$jscomp$loop$prop$m$2.indexOf(".")&&(_e=_d.$jscomp$loop$prop$m$2.split(".")[0],a_[_b][_e]=a_[_b][_e]||{},a_[_b][_e][_d.$jscomp$loop$prop$m$2.split(".")[1]]=function(_d){return function(){a_[_b].queue.push([_d.$jscomp$loop$prop$m$2,arguments])}}(_d)),a_[_b][_d.$jscomp$loop$prop$m$2]=function(_d){return function(){a_[_b].queue.push([_d.$jscomp$loop$prop$m$2,arguments])}}(_d);_d=i_.createElement(r_);_d.async=1;_d.src="//static.airbridge.io/sdk/latest/airbridge.min.js";_g.parentNode.insertBefore(_d,_g)}})(window,document,"script","airbridge","init setBanner setDownload setDeeplinks sendSMS sendWeb setUserAgent setUserAlias addUserAlias setMobileAppData setUserId setUserEmail setUserPhone setUserAttributes setDeviceIFV setDeviceIFA setDeviceGAID events.send events.signIn events.signUp events.signOut events.purchased events.addedToCart events.productDetailsViewEvent events.homeViewEvent events.productListViewEvent events.searchResultViewEvent".split(" "));
var deviceUUID = undefined;
var packageName = undefined;
var isLimitAdTracking = undefined;
try {
deviceUUID = window.AirbridgeDeviceInfo.getDeviceUUID();
packageName = window.AirbridgeDeviceInfo.getPackageName();
isLimitAdTracking = window.AirbridgeDeviceInfo.isLimitAdTracking();
} catch {}
if (typeof deviceUUID === 'string'
&& typeof packageName === 'string'
&& typeof isLimitAdTracking === 'boolean')
{
// when ios app
airbridge.init({
app: 'ablog',
webToken: '8ec37a00b37a4576a7f8bdf8d5164dd5',
mobileApp: {
deviceUUID: deviceUUID,
packageName: packageName,
limitAdTracking: isLimitAdTracking,
}
});
} else {
// when web
airbridge.init({
app: 'ablog',
webToken: '8ec37a00b37a4576a7f8bdf8d5164dd5'
});
}
// when ios app, send web event
// when web, send mobile event
airbridge.events.send('category', {
'label': 'label',
'action': 'action',
'value': 123.0,
'customAttributes': {
'custom1': 123,
'custom2': 'abc'
}
});

Example code - ViewControllerlink

#import "ViewController.h"
#import <WebKit/WebKit.h>
#import <AirBridge/AirBridge.h>
@interface ViewController ()
@end
@implementation ViewController {
WKWebView* webView;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString* insertDeviceInfoSource
= [NSString stringWithFormat:
@"window.AirbridgeDeviceInfo = {};"
@"window.AirbridgeDeviceInfo.getDeviceUUID = function () {"
@" return \'%@\';"
@"};"
@"window.AirbridgeDeviceInfo.getPackageName = function () {"
@" return \'%@\';"
@"};"
@"window.AirbridgeDeviceInfo.isLimitAdTracking = function () {"
@" return %@;"
@"};",
AirBridge.deviceUUID,
NSBundle.mainBundle.bundleIdentifier,
AirBridge.isLimitADTracking ? @"true" : @"false"];
WKUserScript* insertDeviceInfoScript
= [[WKUserScript alloc] initWithSource:insertDeviceInfoSource
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
forMainFrameOnly:NO];
WKUserContentController* controller = [[WKUserContentController alloc] init];
[controller addUserScript:insertDeviceInfoScript];
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
configuration.userContentController = controller;
webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
self.view = webView;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://..."]]];
}
@end

Advancedlink

Direct Install of SDKlink

Framework : Download

Download the above file and drag-and-drop the 'AirBridge.framework' file into the project.

ios framework add

Loglink

Print SDK log.

#import <AirBridge/AirBridge.h>
[AirBridge setLogLevel:AB_LOG_ALL];

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 sendSignup, sendSignin, and expireUser. all events are recorded as being triggered by the user.

#import <AirBridge/AirBridge.h>
[AirBridge.state setUserID:@"testID"];
[AirBridge.state setUserEmail:@"testID@ab180.co"];
[AirBridge.state setUserPhone:@"000-0000-0000"];
[AirBridge.state setUserAttributes:@{@"key": @"value"}];
[AirBridge.state addUserAttributesWithKey:@"key" value:@"value"];
[AirBridge.state setUserAlias:@{@"key": @"value"}];
[AirBridge.state addUserAliasWithKey:@"key" value:@"value"];

The number of User Attributes is up to 100.
User Attributes' key length is up to 128.
The value of User Attributes must be NSNumber or NSString.
If the value of User Attributes is NSString, the length is up to 1024.
The User Attributes' key must satisfy the regular expression ^[a-z][a-z0-9_]*$.

The number of User Alias is up to 10.
User Alias key length is up to 128.
User Alias value length is up to 128.
The User Alias key must satisfy the regular expression ^[a-z_][a-z0-9_]*$.

Manual setting for device informationlink

Enter additional device information.

#import <AirBridge/AirBridge.h>
[AirBridge.state setDeviceAlias:@{@"key": @"value"}];
[AirBridge.state addDeviceAliasWithKey:@"key" value:@"value"];

Maximum count of Device-Alias is 10.
Maximum length of Device-Alias's key is 128.
Maximum length of Device-Alias's value is 128.
Device-Alias's key must meet [a-z_][a-z0-9_]* condition.

When user click push notification, execute below code.

// deeplink obtained from payload of push notifications
NSURL* deeplink = [NSURL URLWithString:...];
if ([deeplink.scheme isEqualToString:@"https"] || [deeplink.scheme isEqualToString:@"http"]) {
[AirBridge.deeplink handleUniversalLink:deeplink];
} else {
// withSourceBundle is always nil
[AirBridge.deeplink handleURLSchemeDeeplink:deeplink withSourceBundle:nil];
}

Send in-app event from WebView (WK)link

You can send in-app events by calling the SDK function through Javascript.

Example code - Javascriptlink

let body = {
category: "category!!",
action: "action!!",
label: "label!!",
value: 12345,
attributes: {
key: "value!!"
}
};
webkit.messageHandlers.goal.postMessage(body);

Example code - ViewControllerlink

@import WebKit;
#import <AirBridge/AirBridge.h>
#import "ViewController.h"
@interface ViewController () <WKUIDelegate, WKScriptMessageHandler>
@end
@implementation ViewController {
WKWebView* web;
}
- (void)loadView {
WKUserContentController* controller = [[WKUserContentController alloc] init];
[controller addScriptMessageHandler:self name:@"goal"];
WKWebViewConfiguration* conf = [[WKWebViewConfiguration alloc] init];
conf.userContentController = controller;
web = [[WKWebView alloc] initWithFrame:CGRectZero configuration:conf];
self.view = web;
}
- (void)viewDidLoad {
[super viewDidLoad];
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://~~~"]]];
}
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
NSDictionary* body = message.body;
if([message.name isEqualToString:@"goal"]) {
[AirBridge.instance goalWithCategory:body[@"category"] action:body[@"body"] label:body[@"label"] value:body[@"value"] customAttributes:body[@"attributes"]];
}
}
@end

If the name of addScriptMessageHandler:name: is @"temp", it should be called as follows.
webkit.messageHandlers.temp.postMessage(body);

Send in-app event from WebView (UI)link

You can send in-app events by calling the SDK function through Javascript.

Example code - Javascriptlink

window.location="jscall://goal?category=custom";

Write the scheme as jscall, host as the name, and parameter values in GET format after '?'.

Example code - ViewController (UIWebView)link

#import <AirBridge/AirBridge.h>
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
@end
@implementation ViewController {
UIWebView* web;
}
- (void)loadView {
web = [[UIWebView alloc] initWithFrame:CGRectZero];
web.delegate = self;
self.view = web;
}
- (void)viewDidLoad {
[super viewDidLoad];
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://~~~"]]];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL* URL = request.URL;
if([URL.scheme isEqualToString:@"jscall"]) {
if([URL.host isEqualToString:@"goal"]) {
NSDictionary* querys = [self getDictionaryWith:URL.query];
[AirBridge.instance goalWithCategory:querys[@"category"]];
}
}
return YES;
}
- (NSDictionary*)getDictionaryWith:(NSString*)query {
NSArray* querys = [query componentsSeparatedByString:@"&"];
NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
for (NSString* query in querys) {
NSArray* pair = [query componentsSeparatedByString:@"="];
if (pair.count > 1) {
result[pair[0]] = [pair[1] stringByRemovingPercentEncoding];
}
}
return result;
}
@end

Get UUID informationlink

Get DeviceUUIDlink

Gets the DeviceUUID.

AirBridge.deviceUUID;

Get ADID tracking permission statuslink

Gets the users' ADID tracking permission status.

AirBridge.isLimitADTracking;

Stop tracking (Opt-out)link

You can stop sending events from the SDK.

AirBridge.isLimitTracking = true;

true : Stop tracking
false : Tracking