在我的iPhone上运行FCM演示应用程序不起作用 - Firebase ID nil 。
重现的步骤:
var dataset = {"nodes":[{"name":"Anglo American plc"},{"name":"Associated British Foods plc"},{"name":"Admiral Group plc"},{"name":"ARM Holdings plc"},{"name":"Aviva plc"},{"name":"BAE Systems plc"},{"name":"Barclays PLC"},{"name":"British American Tobacco p.l.c."},{"name":"The Berkeley Group Holdings plc"},{"name":"BHP Billiton plc"},{"name":"BP p.l.c."},{"name":"BT Group plc"},{"name":"Centrica plc"},{"name":"Compass Group PLC"},{"name":"Direct Line Insurance Group PLC"},{"name":"easyJet plc"},{"name":"International Consolidated Airlines Group, S.A."},{"name":"3i Group plc"},{"name":"Intertek Group plc"},{"name":"Lloyds Banking Group plc"},{"name":"Merlin Entertainments plc"},{"name":"Pearson plc"},{"name":"Reckitt Benckiser Group plc"},{"name":"Royal Dutch Shell plc"},{"name":"Rexam PLC"},{"name":"Rio Tinto plc"},{"name":"SABMiller plc"},{"name":"Schroders plc"},{"name":"Standard Life plc"},{"name":"SSE plc"},{"name":"Standard Chartered PLC"},{"name":"Tesco PLC"},{"name":"Whitbread PLC"}],"edges":[{"source":0,"target":29,"officers":["MEDORI, Rene"]},{"source":0,"target":30,"officers":["GROTE, Byron Elmer"]},{"source":0,"target":31,"officers":["GROTE, Byron Elmer"]},{"source":1,"target":13,"officers":["BASON, John George"]}]};
,并运行pod try Firebase
10: quickstart-ios/messaging/FCM.xcodeproj
文件复制到项目中我的Mac拥有适当的证书来开发和部署应用程序:
我在日志中看到很多噪音,但最重要的错误就是这个:
GoogleService-Info.plist
以下是完整的控制台输出:
Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
答案 0 :(得分:3)
尝试将Firebase / Core更新到v3.4.4,它为我修复了意外错误。否则典型的修复是:
Push Notifications
Capabilities
unregisterForRemoteNotifications
。拨打此电话后,您无法再注册设备以推送通知。FirebaseAppDelegateProxyEnabled
设置为NO
。我认为他们的方法有很多错误。[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeUnknown]
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
答案 1 :(得分:1)
我刚刚在模拟器上运行了相同的代码(iPhone 5,iOS 9.3),我没有遇到任何麻烦。
我确实看到了很多相同的警告,但是......
2016-06-25 16:38:31.353 FCM[2546:42455] Configuring the default app.
2016-06-25 16:38:32.561 FCM[2546:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-06-25 16:38:32.833 FCM[2546:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-06-25 16:38:32.901: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-25 16:38:32.928: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-06-25 16:38:32.971: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-06-25 16:38:33.189: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-25 16:38:51.094: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
2016-06-25 16:38:51.096: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
2016-06-25 16:38:51.140 FCM[2546:42883] CFNetwork SSLHandshake failed (-9806)
2016-06-25 16:38:51.141 FCM[2546:42883] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2016-06-25 16:38:51.460 FCM[2546:42455] Connected to FCM.
2016-06-25 16:38:56.709 FCM[2546:42455] InstanceID token: fgbPv5tnsPk:APA91bHUWOmuLmd4UkLXcp3Lysp92fH6bOb7tfmbjHehFOt_NPnc6tnMk-7YT51VASkk-dyHZAl01QRcedwqGUhHMiIXeV_xknBXppncu0WyjKLYhaVQ08bYKNZ5M1CuSjtk9l0HPyJX
2016-06-25 16:38:56.711 FCM[2546:42455] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)"
2016-06-25 16:38:57.505 FCM[2546:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-06-25 16:40:03.845 FCM[2546:42455] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)"
2016-06-25 16:40:06.534 FCM[2546:42455] InstanceID token: fgbPv5tns9......
答案 2 :(得分:1)
除了在您的开发计算机上安装APNs SSL证书外,您还需要将它们上传到Firebase控制台!
https://console.firebase.google.com/project/your-project-name-here/settings/cloudmessaging
答案 3 :(得分:0)
问题是由于我使用了“生产”SSL证书,而不是“开发”证书。安装它似乎解决了问题。
我错误地认为开发版和生产版都将由“Apple推送通知服务SSL(沙盒和生产)”证书处理。对于本机APN可能就是这种情况,但它对Firebase不起作用。
答案 4 :(得分:0)
如果您碰巧运行此命令:
[[UIApplication sharedApplication] unregisterForRemoteNotifications],
您的应用无法注册远程通知。
registerusernotificationsettings not work after using unregisterForRemoteNotifications
您需要卸载该应用才能让它再次运行...
答案 5 :(得分:0)
对我来说,如果我在从Firebase获取值之前没有使用FIRAuth,那就发生了。
FIRAuth.auth()?.signIn(withEmail: "test1@gmail.com", password: "123456", completion: { (user, error) in
if(error != nil){
print(error)
return
}
let ref = FIRDatabase.database().reference(fromURL: "https://firdemo-84b6b.firebaseio.com/").child("users")
ref.observe(.value, with: { (snapshot) in
print(snapshot.key)
print(snapshot.value)
}, withCancel: { (error) in
if(error != nil){
print(error)
return
}
})
})
请试一试。如果它不起作用,请告诉我。
答案 6 :(得分:0)
在Cloud Messaging选项卡中的Firebase中添加APNS.p12
https://console.firebase.google.com/project/VBTechlabsApp(YOUR_APP_NAME)/settings/cloudmessaging