iOS: Auto Integration

SDK auto integration details

By default the iOS SDK will integrate with the push notification handling in your application, allowing it to process notification data and settings without any manual integration steps on your part. However, there are some libraries that can conflict with this auto integration and some situations where you may desire more manual control over this handling. In these cases, you can turn off auto integration using the following method.

[[Marigold new] setAutoIntegrationEnabled:NO];



You must disable auto integration before calling the startEngine method.

Once auto integration has been turned off, there are some extra methods you will need to implement in your application in order for the SDK to receive push notification related data.

UNUserNotificationCenterDelegate methods

These methods are called in your UNUserNotificationCenterDelegate implementation. You need to set this in the UNUserNotificationCenter in order to handle push notifications in your app from iOS 10+.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    // Pass the notification to the SDK
    [[Marigold new] handlePresentNotification:notification];
    // Call the completion handler
    completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    // Pass the notification to the SDK
    // Call the completion handler
    completionHandler([.badge, .sound])

The userNotificationCenter:willPresentNotification:withCompletionHandler: method is called when a notification is received when the application is running in the foreground.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    // Pass the notification response to the SDK.
		[[Marigold new] handleNotificationResponse:response];

    // Call the completion handler
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    // Pass the notification response to the SDK.
    // Call the completion handler

The userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: method is called when a notification has been interacted with by the user, which can be:

  • Tapping the notification
  • Tapping a notification action
  • Dismissing the notification, if custom dismissal handling has been requested for that category

UNUserNotificationCenter methods

After requesting push notification authorization from the UNUserNotificationCenter you can update the platform with the authorized notification options using the following method.

[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:options completionHandler:^(BOOL granted, NSError * _Nullable error) {
  	// Send push authorization settings to platform
    [[Marigold new] syncNotificationSettings];
UNUserNotificationCenter.current().requestAuthorization(options: options) { (granted, error) in
    // Send push authorization settings to platform

UIApplicationDelegate methods

These methods are called in your application's UIApplicationDelegate implementation and include token handling and push payload handling.

- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [[Marigold new] setDeviceTokenInBackground:deviceToken];
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

The application:didRegisterForRemoteNotificationsWithDeviceToken: method is called when an app has registered for remote notifications using the [[UIApplication sharedApplication] registerForRemoteNotifications] method. It will be called to return the APNS token to the application, which must then be supplied to in the SDK in order for the platform to send push notifications to the device.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    // Call the completion handler
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    // Pass the notification payload to the SDK.
    // Call the completion handler

The application:didReceiveRemoteNotification:fetchCompletionHandler: is called at the time the notification is received (if possible). If your app has requested permission to launch in the background for remote notifications and the app is not running, it will launch the app into the background if it can to handle this method. However, it will not launch if the user has manually cleared the app from memory.