Integrate the iOS SDK

Use the Xtremepush SDK to integrate your iOS App with the Platform

  1. To initialise Xtremepush you must modify your Application Delegate. Inside application didFinishLaunchingWithOptions add the following code to import the XPush SDK:
import XPush
#import <XPush/XPush.h>
  1. Inside applicationDidFinishLaunching:withOptions add the following, replacing XPUSH_APP_KEY with the SDK application key provided when adding the app to the platform :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {    
    XPush.setAppKey("XPUSH_APP_KEY")
    #if DEBUG
    // Show Debug logs in debug builds
    XPush.setShouldShowDebugLogs(true)
    #endif
    XPush.applicationDidFinishLaunching(options: launchOptions)    
    return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [XPush setAppKey: @"XPUSH_APP_KEY"];
    #if DEBUG
    // Show Debug logs in debug builds
    [XPush setShouldShowDebugLogs:YES]; 
    #endif 
    [XPush applicationDidFinishLaunchingWithOptions:launchOptions];
}
  1. In case your project is provisioned in US shared cloud, add the following code after XPush.setAppKey:
XPush.setServerURL("https://sdk.us.xtremepush.com")
[XPush setServerURL: @"https://sdk.us.xtremepush.com"];
  1. In the event your project is provisioned in the US Region, alongside setting the Server URL, you will also need to implement Public Key Pinning
 let path = Bundle.main.path(forResource: "cert", ofType: "der")
 XPush.setServerExpectedCertificateFromFile(path)
NSString* path = [[NSBundle mainBundle] pathForResource:@"cert" ofType:@"der"];
[XPush setServerExpectedCertificateFromFile:path];

Add description for CoreBluetooth

Since iOS 10 NSBluetoothPeripheralUsageDescription is required to be set if your app includes CoreBluetooth, even if it is not actively used. As the Xtremepush SDK includes CoreBluetooth you must add the NSBluetoothPeripheralUsageDescription key and associated usage description to your Info.plist file.

👍

If you're not using the SDK's Bluetooth features for iBeacons, you could just set the description to something simple like "Using Bluetooth".

This usage description is only used when Acts as a Bluetooth LE accessory is added to background modes. The Xtremepush SDK does not use this mode, and iBeacon support is only enabled by following the instructions in iOS location permissions. Unless you use Acts as a Bluetooth LE accessory elsewhere in your app, this will not be shown to the user.

Failure to include this description key will result in an automated rejection when uploading your app to the App Store and an email notification similar to the one below:

👍

Make sure you set the user ID

It is recommended that at this stage you use our SDK method to set user IDs by following our dedicated guide to ensure devices can be associated and targeted in your campaigns by your own unique identifier.