web-dev-qa-db-fra.com

Notification push non reçue dans iOS 10

Mon application est dans l'Appstore. La notification push fonctionne bien dans iOS 9, mais dans iOS 10, cela ne fonctionne pas. Je ne reçois aucune notification Push pour les appareils iOS 10. J'ai vérifié le jeton d'appareil et le certificat sur mon serveur. Tout est correct. J'ai également vérifié les propriétés de notification dans l'application des paramètres. Tout va bien. Mais je n'ai reçu aucune notification. Je viens de désactiver et d'activer la notification pour mon application. Et j'ai ouvert mon application pour vérifier si le jeton de l'appareil change ou non. Il est modifié et mis à jour sur mon serveur. Ensuite, je reçois correctement la notification. Cela fonctionne bien maintenant pour mon appareil.

Je me demande si cela affectera tous les utilisateurs ou seulement moi. Quiconque trouve la solution appropriée, faites-le moi savoir.

Merci d'avance

9
Yogesh Mv

Besoin de quelques modifications pour iOS 10 avec xCode 8 GM Vous devez implémenter UserNotifications.framework et leurs méthodes déléguées pour obtenir le travail des notifications Push.

J'ai résolu mon problème en utilisant le nouveau cadre UserNotifications.fr. Veuillez suivre ce lien: Problème de notification push avec iOS 1

7
Ashish Shah

"serNotifications" n'est pas obligatoire dans iOS10. "IUserNotificationSettings" fonctionne toujours dans iOS10.

Si vous avez le code suivant, il devrait fonctionner dans iOS10.

[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

Mais si vous construisez avec Xcode8 et supérieur, assurez-vous que vous avez l'entrée suivante dans votre droits. Cette entrée sera ajoutée automatiquement une fois que vous aurez activé "Notifications push" dans "Capacités".

<key>aps-environment</key>
<string>development</string>

Dans la version de distribution-distribution, cela sera automatiquement modifié comme suit

<key>aps-environment</key>
<string>production</string>
7
arango_86

Nous devons changer du code pour iOS 10.

Appdelegate.h

#import <UserNotifications/UserNotifications.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate> 
@end

Vérifier la version du système d'exploitation

#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

Enregistrer la notification

- (void)registerForRemoteNotifications {
    if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")){
        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
        center.delegate = self;
        [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
             if(!error){
                 [[UIApplication sharedApplication] registerForRemoteNotifications];
             }
         }];  
    }
    else {
        // Code for old versions
    }
}

Méthode déléguée Handel

//foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
    NSLog(@"User Info : %@",notification.request.content.userInfo);
    completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
    NSLog(@"User Info : %@",response.notification.request.content.userInfo);
    completionHandler();
}
3
Keyur Hirani

Sur iOS 10 est nécessaire ajouter le droit de notifications push, donc si vous "Résoudre le problème" dans les capacités, le problème sera résolu automatiquement.

1
raul