我正在开发一个使用Firebase推送通知的应用程序。在我尝试使用iOS11之前,它运行得很好。使用iOS11时,iOS无法收到通知。下面是我的代码:
- (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
}
这两个方法都不会被调用。
谢谢你的帮助!
发布于 2017-09-28 06:57:02
这是Firebase的一个问题。这似乎与他们最近的一次更新有关,而不是iOS 11。他们正在努力修复它。
同时,如果您将pod 'FirebaseInstanceID', '2.0.0'
添加到您的播客文件中,它将修复它。
你可以在这里阅读更多内容:https://github.com/firebase/quickstart-ios/issues/327#issuecomment-332655731
发布于 2017-09-23 03:13:51
您需要实现UNUserNotificationCenterDelegate
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
}
并将其设置为didFinishLaunchingWithOptions
内的UNUserNotificationCenter
对象
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
return true
}
发布于 2017-09-28 02:00:29
在你的项目能力中检查这一点。这对我很有帮助)
https://stackoverflow.com/questions/46345500
复制相似问题