FireBase iOS 消息传递,无法获取 APNS 令牌
FireBase iOS Messaging, fails to fetch APNS Token
好吧,我花了一半的昨天和一半的时间在看板和 Google 以及 Firebase Docs 上寻找解决方案。只是为了清楚。
我在我的 info.plist 中将 FirebaseAppDelegateProxyEnabled 设置为 NO,我将 post 我的 appDelegate 方法,但我已经多次查看文档:
didFinishLaunchingWithOptions:
customizeAppearance()
FIRApp.configure()
tracker.appLaunch()
registerForPushNotifications(application)
notificationCenter.addObserver(self, selector: #selector(AppDelegate.tokenRefreshNotification), name: kFIRInstanceIDTokenRefreshNotification, object: nil)
return PersistentStoreManager.sharedInstance.managedObjectContextHasBeenInitialized()
didReceiveRemoteNotification:
//Full message
print("%@", userInfo)
articleID = "\(userInfo["articleId"]!)"
notificationCenter.postNotificationName("newArticle", object: nil)
registerForPushNotifications:
let notificationSettings = UIUserNotificationSettings(
forTypes: [.Badge, .Sound, .Alert], categories: nil)
application.registerUserNotificationSettings(notificationSettings)
application.registerForRemoteNotifications()
didRegisterForRemoteNotificationsWithDeviceToken:
//send the APNs token to firebase
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox)
print("In did register For remote Not with token: \(FIRInstanceID.instanceID().token())")
}
令牌刷新通知:
let refreshedToken = FIRInstanceID.instanceID().token()!
//send token information to server
self.manager.sendNotificationToken(refreshedToken)
//double check to connect to FCM, may have failed when attempted before having a token
connectToFcm()
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print("Failed to register:", error.description)
}
控制台日志:
WARNING: Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
Configuring the default app.
<FIRAnalytics/INFO> Firebase Analytics v.3201000 started
<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
<FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "The operation couldn’t be completed. (com.firebase.iid error 1001.)"
<FIRMessaging/INFO> FIRMessaging library version 1.1.0
[4459:501] <FIRAnalytics/INFO> Firebase Analytics enabled
CFNetwork SSLHandshake failed (-9806)
2016-07-28 10:26:08.245: <FIRInstanceID/WARNING> APNS Environment in profile: development
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")
我的目标是 iOS 8.3 及更高版本。我也将我的开发和生产推送通知证书上传到 Firebase。
我设置了断点,我的 tokenRefreshNotification() 没有被调用,didReceiveRemoteNotification() 也没有被调用
我不知道出了什么问题,我应该在星期一将应用程序发送到应用程序商店。昨天大部分时间我都收到通知,然后他们停止了。我没有从 Firebase 控制台或我们的 Web 服务服务器获取它们。
好的,我发现了我的问题。如果其他人遇到这个问题,我想 post 解决方案。请务必检查您的代码签名身份和配置文件。我不确定我昨天发生了什么变化,但是每当我修复这些代码签名设置时,我的推送通知都非常棒,我还没有错过任何一个。
好吧,我花了一半的昨天和一半的时间在看板和 Google 以及 Firebase Docs 上寻找解决方案。只是为了清楚。
我在我的 info.plist 中将 FirebaseAppDelegateProxyEnabled 设置为 NO,我将 post 我的 appDelegate 方法,但我已经多次查看文档:
didFinishLaunchingWithOptions:
customizeAppearance()
FIRApp.configure()
tracker.appLaunch()
registerForPushNotifications(application)
notificationCenter.addObserver(self, selector: #selector(AppDelegate.tokenRefreshNotification), name: kFIRInstanceIDTokenRefreshNotification, object: nil)
return PersistentStoreManager.sharedInstance.managedObjectContextHasBeenInitialized()
didReceiveRemoteNotification:
//Full message
print("%@", userInfo)
articleID = "\(userInfo["articleId"]!)"
notificationCenter.postNotificationName("newArticle", object: nil)
registerForPushNotifications:
let notificationSettings = UIUserNotificationSettings(
forTypes: [.Badge, .Sound, .Alert], categories: nil)
application.registerUserNotificationSettings(notificationSettings)
application.registerForRemoteNotifications()
didRegisterForRemoteNotificationsWithDeviceToken:
//send the APNs token to firebase
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox)
print("In did register For remote Not with token: \(FIRInstanceID.instanceID().token())")
}
令牌刷新通知:
let refreshedToken = FIRInstanceID.instanceID().token()!
//send token information to server
self.manager.sendNotificationToken(refreshedToken)
//double check to connect to FCM, may have failed when attempted before having a token
connectToFcm()
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print("Failed to register:", error.description)
}
控制台日志:
WARNING: Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
Configuring the default app.
<FIRAnalytics/INFO> Firebase Analytics v.3201000 started
<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
<FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "The operation couldn’t be completed. (com.firebase.iid error 1001.)"
<FIRMessaging/INFO> FIRMessaging library version 1.1.0
[4459:501] <FIRAnalytics/INFO> Firebase Analytics enabled
CFNetwork SSLHandshake failed (-9806)
2016-07-28 10:26:08.245: <FIRInstanceID/WARNING> APNS Environment in profile: development
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")
In did register For remote Not with token: Optional("fWmrxcdNICg:APA91bF_pVwLixBXFuRZEF0w64J7zizSQfpaYNjJhf9g95fZxDmqKD-I1gnaxufkmbNvGZZKs8ifL6ZlXY9nWBc0utgVjEBJG7tUNnA8ciOzeyW9wtfSHyq0IYIf4OepJ4qTJf8qLpIR")
我的目标是 iOS 8.3 及更高版本。我也将我的开发和生产推送通知证书上传到 Firebase。
我设置了断点,我的 tokenRefreshNotification() 没有被调用,didReceiveRemoteNotification() 也没有被调用
我不知道出了什么问题,我应该在星期一将应用程序发送到应用程序商店。昨天大部分时间我都收到通知,然后他们停止了。我没有从 Firebase 控制台或我们的 Web 服务服务器获取它们。
好的,我发现了我的问题。如果其他人遇到这个问题,我想 post 解决方案。请务必检查您的代码签名身份和配置文件。我不确定我昨天发生了什么变化,但是每当我修复这些代码签名设置时,我的推送通知都非常棒,我还没有错过任何一个。