didReceiveRemoteNotification未通过FCM接收通知

时间:2017-09-21 10:43:23

标签: ios swift3 firebase-cloud-messaging unusernotificationcenter remote-notifications

我已根据其网站上的说明实施了Firebase云消息传递。所以当我从这里生成通知时: enter image description here

branch_a我已将AppDelegate.swift函数添加为:

didReceiveRemoteNotification

我实施的其他方法是
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) print(userInfo) completionHandler(UIBackgroundFetchResult.newData) }
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage)

我的func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)有:

didFinishLaunchingWithOptions

1 个答案:

答案 0 :(得分:1)

请看一下这个要点文件 AppDelegate file for FCM

在XCode转到目标>能力与能力确保您的推送通知已启用。 enter image description here 希望它有所帮助。