![](/img/trans.png)
[英]How can I detect when the real iOS/APNS push token is registered with Firebase Cloud Messaging (FCM)?
[英]FireBase iOS Messaging, fails to fetch APNS Token
好的,我花了昨天的一半時間和今天早上的一半時間在董事會和Google以及Firebase Docs上搜索解決方案。 只是要清楚。
我在info.plist中將FirebaseAppDelegateProxyEnabled設置為NO,我將發布我的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())")
}
tokenRefreshNotification:
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服務服務器上獲得它們。
好的,我發現了我的問題。 如果有人遇到這個問題,我想發布解決方案。 確保檢查您的代碼簽名身份和配置文件。 我不確定昨天是否發生了什么變化,但是,每當我修復這些代碼簽名設置時,我的推送通知就大功告成了,我還沒有錯過任何一個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.