Je développe une application qui utilise les notifications push Firebase. Cela a bien fonctionné jusqu'à ce que j'ai essayé dans iOS 11. En utilisant un iphone avec ios 11 les notifications n'arrivent pas. Voici mon code:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^) (UIBackgroundFetchResult))completionHandler { //Manage notification } - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{ //Manage notification }
Aucune des deux methods n'est appelée.
Merci pour l'aide!
C'est un problème avec Firebase. Il semble être lié à une mise à jour récente des leurs au lieu d'iOS 11. Ils travaillent sur un correctif pour cela.
En attendant, si vous ajoutez le pod 'FirebaseInstanceID', '2.0.0'
à votre podfile, il le réparera.
Vous pouvez en lire plus ici: https://github.com/firebase/quickstart-ios/issues/327#issuecomment-332655731
Vous devez implémenter UNUserNotificationCenterDelegate
extension AppDelegate: UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler(.alert) } }
et définissez-le à l'object didFinishLaunchingWithOptions
intérieur de didFinishLaunchingWithOptions
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { UNUserNotificationCenter.current().delegate = self return true }
Vérifiez ceci dans votre capacité de projet. Cela m'a aidé)
Pouvez-vous essayer cela
Messaging.messaging().delegate = self Messaging.messaging().shouldEstablishDirectChannel = true