Advanced Configuration

The SDK provides a number of advanced configuration features that are defined by the UAConfig class. Only a subset of options will be outlined in this guide. For a full list of options, check out the available properties on the UAConfig class.

Every option is able to be defined by the AirshipConfig.plist by setting the corresponding UAConfig property name to the desired value. Alternatively you can define any value programmatically by setting properties directly on a UAConfig instance and providing it during UAirship takeOff: .

Overriding `AirshipConfig.plist` programmatically
// Defaults to any value in AirshipConfig.plist
let config = UAConfig.default()

// Set any custom values
config.developmentAppKey = "DEV APP KEY"
config.developmentAppSecret = "DEV APP SECRET"

// TakeOff with custom config
UAirship.takeOff(config)
// Defaults to any value in AirshipConfig.plist
UAConfig *config = [UAConfig defaultConfig];

// Set any custom values
config.developmentAppKey = @"DEV APP KEY"
config.developmentAppSecret = @"DEV APP SECRET"

// TakeOff with custom config
[UAirship takeOff:config];

Automatic Integration

The Airship SDK will automatically integrate with your app, so you do not need to implement any of the push-related UIApplicationDelegate or UNUserNotificationCenterDelegate protocol methods. The SDK is able to do this by intercepting app delegate messages and forwarding them to your original app delegate, using a technique known as method swizzling.

This should be compatible with the vast majority of applications out of the box, but if you have advanced use cases for your app delegate, or if you would otherwise prefer to disable this behavior, you can set automaticSetupEnabled to NO.

If you choose to disable automatic integration, you will need to forward the appropriate methods to the Airship SDK.

Manual integration
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Set up the UNUserNotificationCenter delegate
    UNUserNotificationCenter.current().delegate = self
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    UAAppIntegration.application(UIApplication.shared, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    UAAppIntegration.application(UIApplication.shared, didFailToRegisterForRemoteNotificationsWithError: error)
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    UAAppIntegration.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
}

// UNUserNotificationCenterDelegate methods

func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (options: UNNotificationPresentationOptions) -> Void) {
    UAAppIntegration.userNotificationCenter(center,
        willPresentNotification: notification,
        withCompletionHandler: completionHandler)
}

func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
    UAAppIntegration.userNotificationCenter(center,
    didReceiveNotificationResponse: response,
    withCompletionHandler: completionHandler)
}
// UIApplicationDelegate methods

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Set up the UNUserNotificationCenter delegate
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [UAAppIntegration application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    [UAAppIntegration application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [UAAppIntegration application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

// UNUserNotificationCenterDelegate methods

- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    [UAAppIntegration userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
}

- (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
    [UAAppIntegration userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

Logging

Log levels can be set independently for production and development modes by setting developmentLogLevel and productionLogLevel config options.