PhoneGap multiple push providers

By default, the Xtremepush iOS Phonegap plugin uses method swizzling to inject the required AppDelegate methods for push handling. If you have multiple push providers in your Cordova-based application this can interfere with your existing setup so instead, the plugin's method swizzling can be disabled and the AppDelegate methods can be updated manually to call the Xtremepush SDK as required.

Switching to manual method configuration

  1. Disable swizzling by putting a boolean flag for XPushSwizzlingDisabled in your Info.plist to YES.
  2. Confirm that each of the following methods is present in your AppDelegate.m file and add call the relevant Xtremepush SDK methods from each, as shown below:

Here's a sample implementation:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\
{\
    [XPush applicationDidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    [XPush applicationDidFailToRegisterForRemoteNotificationsWithError:error];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    [XPush applicationDidReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
-(void)application:(UIApplication *) didReceiveLocalNotification:(UILocalNotification *)localNotification
{
    [XPush applicationDidReceiveLocalNotification:notification];
}

If using UNUserNotificationCenter:

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

If you need to check if a message has come from Xtremepush, so you can ignore it, please see the further information on the main docs page for supporting Multiple Push Providers


Did this page help you?