Provedores múltiplos push PhoneGap

Prev Next

Por padrão, o plugin Xtremepush iOS Phonegap usa o método swizzling para injetar os métodos AppDelegate necessários para o gerenciamento de push. Se você tiver múltiplos provedores push no seu aplicativo baseado em Cordova, isso pode interferir na sua configuração atual, então o método swizzling do plugin pode ser desativado e os métodos AppDelegate podem ser atualizados manualmente para chamar o SDK Xtremepush conforme necessário.

Mudança para a configuração manual do método

  1. Desative o swizzling colocando uma bandeira booleana para XPushSwizzlingDisabled em seu Info.plist .YES

  2. Confirme que cada um dos métodos a seguir está presente no seu AppDelegate.m arquivo e adicione a chamada de chamada dos métodos relevantes do Xtremepush SDK de cada um, conforme mostrado abaixo:

Aqui está um exemplo de implementação:

- (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];
}

Se usar UNUserNotificationCenter:

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

Se você precisar verificar se veio uma mensagem do Xtremepush para ignorá-la, por favor, veja as informações adicionais na página principal de documentação para suporte a Múltiplos Provedores de Push