web-dev-qa-db-fra.com

Les notifications push iOS 12 ne fonctionnent pas et fonctionnent dans les versions ci-dessous, la notification push ne reçoit pas dans iOS 12

Pour iOS 12, les notifications push ne fonctionnent pas et fonctionnent dans les versions ci-dessous

Mon application est dans l'Appstore. La notification push fonctionne correctement dans iOS 11, mais dans iOS 12, elle ne fonctionne pas. Je ne reçois aucune notification Push pour les appareils iOS 12. J'ai vérifié le jeton et le certificat de l'appareil 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.

C'est le code que j'ai utilisé pour les notifications Push.

Pouvez-vous me suggérer quel serait le problème? Comment régler ceci?

func registerForPushNotifications() {

    if #available(iOS 10.0, *){

        let center = UNUserNotificationCenter.current()
        center.delegate = self
        center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
            if (granted)
            {
                UIApplication.shared.registerForRemoteNotifications()
            }
            else{
                //Do stuff if unsuccessful...
                 UIApplication.shared.registerForRemoteNotifications()
            }
            // Enable or disable features based on authorization.
        }
    }
    else
    {

        let types: UIUserNotificationType = [UIUserNotificationType.badge, UIUserNotificationType.alert, UIUserNotificationType.sound]
        let settings: UIUserNotificationSettings = UIUserNotificationSettings( types: types, categories: nil )
        UIApplication.shared.registerUserNotificationSettings( settings )
        UIApplication.shared.registerForRemoteNotifications()

    }

}



@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    let userInfo = response.notification.request.content.userInfo as NSDictionary

    print(userInfo)


}
9
Sandeep Baddula

J'ai eu le même problème lorsque mon application fonctionnait en "débogage",
J'exécute l'application dans "release" et la notification a bien fonctionné

2
Yusef.Naser