Oracle Help Center | Oracle Responsys Mobile App Platform Cloud Service title

Multiple Push SDKs

This topic provides steps for configuring your mobile app to identify and display push notifications from Responsys when using multiple push SDKs in the same app. Before proceeding, ensure that you have followed through the Step-by-Step guide and any other feature-specific guides available in the Responsys Help Center.

Overview

The Responsys Mobile SDK supports co-existing with other push provider SDKs within the same app. While we do not certify this behavior with other providers individually, as long as the other SDKs follow the standard Apple Development Guidelines, there should be no issues with such integrations.

Let's get started!


Step 1: Disable Swizzling

Some SDKs allow automatic setup with the help of method swizzling. If method swizzling is enabled, your non-Responsys SDKs can automatically intercept all of the AppDelegate methods and take control of your app. Therefore, swizzling needs to be disabled for the Responsys SDK to co-exist with other SDKs.

Refer to your SDK's documentation to disable swizzling or automatic setup.

Step 2: Setup and Register

You must configure the Responsys SDK, register the SDK with APNs, and register the SDK with the Responsys platform.

    //1. Import the UserNotifications.h
     #import <UserNotifications/UserNotifications.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    //2. Set the UNUserNotificationCenter delegate
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
    
    //3. PushIOManger Setup and Registration
    [[PushIOManager sharedInstance] setLogLevel:PIOLogLevelVerbose]; //For debugging only

    [[PushIOManager sharedInstance] configureWithFileName:@"c.json" completionHandler:^(NSError *error, NSString *response) {
        if(nil == error)
        {
            NSLog(@"SDK Configured Successfully");
            [[PushIOManager sharedInstance] registerForAllRemoteNotificationTypes:^(NSError *error, NSString *deviceToken)
             {
                 if (nil == error) {
                     NSError *regTrackError = nil;
                     [[PushIOManager sharedInstance] registerApp:&regTrackError completionHandler:^(NSError *regAppError, NSString *response)
                      {
                          if (nil == regAppError){
                              NSLog(@"Application registered successfully!");
                          }else{
                              NSLog(@"Unable to register application, reason: %@", regAppError.description);
                          }
                      }];
                 } else {
                     NSLog(@"Unable to register application, reason: %@", error.description);
                 }
             }];

        }
        else
        {
            NSLog(@"Unable to configure SDK, reason: %@", error.description);
        }
        
    }];

    //4. ** Other SDK Setup and Registration Code ** - Disable swizzling here


    //Call at the end
    [[PushIOManager sharedInstance] didFinishLaunchingWithOptions:launchOptions];
    return YES;
}
        
  //1. Import the UserNotifications
  import UserNotifications

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        //2. Set the UNUserNotificationCenter delegate
        UNUserNotificationCenter.current().delegate = self
        
        //3. Setup the PushIOMangaer
        PushIOManager.sharedInstance()?.configure(withFileName: "YOUR_PUSHIO_CONFIG.json", completionHandler: { (error, response) in
            if let error = error {
                print("Unable to configure sdk, reason: \(error)")
            } else {
                PushIOManager.sharedInstance().register(forAllRemoteNotificationTypes: { (regTrackError, deviceToken) in
                    if (regTrackError == nil){
                        print("Device Token: \(String(describing: deviceToken))")
                        do {
                            // Register application with SDK.
                            try PushIOManager.sharedInstance().registerApp(completionHandler: { (regError, response) in
                                if (regError == nil) {
                                    print("Registration successful")
                                } else {
                                    print("Unable to register, reason: \(String(describing: regError))")
                                }
                            })
                        } catch {
                            print("Unable to track registration locally, reason: \(error)")
                        }
                    }
                })

            }
        })
        //4. ** Other SDK Setup and Registration Code ** - Disable swizzling here
        
        
        //Call at the end
        PushIOManager.sharedInstance()?.didFinishLaunching(options: launchOptions)
        return true
    }

        

Step 3: Implement Delegate Methods

Next, implement delegate methods and call the Responsys SDK APIs. Your other SDKs should also provide similar APIs. You'll need to call the specific SDK's APIs based on the push payload received by the device. When a new push notification is received by the device, it is important to identify the source of the push notification, and direct the payload to the correct SDK accordingly. The Responsys Mobile SDK v6.42 and later provide convenient methods to identify if the push notification originated from Responsys, and then forwards the push notification to the Responsys Mobile SDK.

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:
(NSData *)deviceToken
{
    [[PushIOManager sharedInstance]  didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

    //** Call Other SDKs ``didRegisterForRemoteNotificationsWithDeviceToken:`` method
}


- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{

    [[PushIOManager sharedInstance] didFailToRegisterForRemoteNotificationsWithError:error];

    //** Call Other SDKs ``didFailToRegisterForRemoteNotificationsWithError:`` method

}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    
    if ([[PushIOManager sharedInstance] isResponsysPayload: userInfo]) { 
        [[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo];
    } else {
        //** Call Other SDKs ``didReceiveRemoteNotification:`` method
    }
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    if ([[PushIOManager sharedInstance] isResponsysPayload:userInfo ]) { 
        [[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo
                                               fetchCompletionResult:UIBackgroundFetchResultNewData fetchCompletionHandler:completionHandler];
    } else {
        //** Call Other SDKs ``didReceiveRemoteNotification:fetchCompletionHandler:`` method
    }
}

// UNUserNotificationCenterDelegate methods

- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    
    if ([self isResponsysPayload: notification.request.content.userInfo ]) { 
        [[PushIOManager sharedInstance] userNotificationCenter:center willPresentNotification:notification
                                         withCompletionHandler:completionHandler];
    } else {
        //** Call Other SDKs ``willPresentNotification:`` method
    }
}

- (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    if ([self isResponsysPayload: response.notification.request.content.userInfo ]) { 
        [[PushIOManager sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response
                                         withCompletionHandler:completionHandler];
    } else {
        //** Call Other SDKs ``didReceiveNotificationResponse:`` method
    }
}
        
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
     PushIOManager.sharedInstance()?.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)

    //** Call Other SDKs ``didRegisterForRemoteNotificationsWithDeviceToken:`` method
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    PushIOManager.sharedInstance()?.didFailToRegisterForRemoteNotificationsWithError(error)

    //** Call Other SDKs ``didFailToRegisterForRemoteNotificationsWithError:`` method
}
    
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    if PushIOManager.sharedInstance().isResponsysPayload(userInfo) {
        PushIOManager.sharedInstance().didReceiveRemoteNotification(userInfo, fetchCompletionResult: UIBackgroundFetchResult.newData, fetchCompletionHandler: completionHandler)
    } else {
        //** Call Other SDKs ``didReceiveRemoteNotification userInfo:`` method
    }
}

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    if PushIOManager.sharedInstance().isResponsysNotificationResponse(response) {
        PushIOManager.sharedInstance().userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
    } else {
        //** Call Other SDKs ``didReceive response:`` method
    }
}
    
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    if PushIOManager.sharedInstance().isResponsysNotificaton(notification)  {
        PushIOManager.sharedInstance()?.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
    } else {
        //** Call Other SDKs ``willPresent notification:`` method
    }
}