360dialog iOS SDK

This is the 360dialog mobile SDK. You can find below the insturctions for a quick start. For more detailed documentation, please refer to our Developer Portal

badge-languages badge-pms

Installation

CocoaPods

You can install the 360dialog SDK using CocoaPods by adding the following to your Podfile:

Add D360 to your Podfile:

# Podfile
platform :ios, '8.0'

# The usage of frameworks is optional but recommended.
use_frameworks!

source 'git@github.com:360dialog/d360-cocoapods-specs.git'

pod 'D360Kit', '~> 3.8'

Carthage

  • Add the 360 SDK repository line to your Cartfile and run carthage update --use-ssh
# Cartfile
github "360dialog/sdk-ios" ~> 3.7

Starting the SDK

Start the 360dialog SDK in the -[AppDelegate application:didFinishLaunchingWithOptions:] as follows

D360Options *options = [D360Options optionsWithAppId:@"12345" apiKey:@"00000000000000000"];
[D360 startWithOptions:options];

Note: Be sure to replace the appId and apiKey values with the ones from your application dashboard. These values can also be taken from the API.

Remote Notification

For the 360dialog SDK to work properly, you need to implement those UIApplicationDelegate methods

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    // Send the device token to 360 servers
    [[D360 push] registerDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
    // let the 360 SDK handle the push
    if (![[D360 push] handleNotification:userInfo fetchCompletionHandler:completionHandler]) {

        // When this is not a D360 push, you need to call the completion yourself
        completionHandler(UIBackgroundFetchResultNewData);
    }
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

    [[D360 push] handleNotification:userInfo fetchCompletionHandler:nil];
}

If you have deep links campaings setup, the 360 SDK will call the UIApplicationDelegate methods as if your application was open you will have to handle the deep link opening in your.

#pragma - Deep Links

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    [[D360 urls] reportOpenURL:url sourceApplication:sourceApplication];

    // Handle the deep link here as you normally would

    return YES;
}

// Of if you are targeting iOS 9+ only

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options
{

    [[D360 urls] reportOpenURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];

    // Handle the deep link here as you normally would

    return YES;
}

Events

You can send any custom events with optional key/value parameters using

NSDictionary *parameters = @{
                             @"productCategory": @"computers",
                             @"productId": @(123)
                             };

[[D360 events] logCustomEventWithName:@"custom_event" parameters:parameters];

or use the predefined SDK methods such as

[[D360 events] logAddToCartWithProductIdentifier:@"AB123456789"
                                     productName:@"iPhone 7"
                                    productPrice:[NSDecimalNumber decimalNumberWithString:@"759"]
                                        currency:@"EUR"
                                      parameters:nil];

See the D360EventService class for more.