[英]Firebase push notifications not working for production on iOS
I integrated Firebase Messaging SDK into my iOS project, created a push notification certificate for development and one for production, uploaded both p12 keys to Firebase and I do not receive the notifications, but just for development. 我将Firebase Messaging SDK集成到我的iOS项目中,创建了一个用于开发的推送通知证书和一个用于生产的推送通知证书,将p12密钥均上载到Firebase,但我没有收到通知,而只是为了开发。
The code for registration is good, and it is the same I used for usual APNS, which worked fine. 注册代码很好,与我通常用于APNS的代码相同,效果很好。
The same behaviour happens for 3 applications. 3个应用程序发生相同的行为。
Did someone else encounter this problem? 有人遇到过这个问题吗? Do you have any solutions or suggestions?
您有什么解决方案或建议吗?
I had the same issue. 我遇到过同样的问题。 Apparently there is an error in the Firebase documentation.
显然,Firebase文档中存在错误。 When you exporting the APN certificate for production from your keychain to the .p12 file you have to select the actual certificate, not the private key .
当您将用于生产的APN证书从钥匙串导出到.p12文件时,必须选择实际的证书, 而不是私钥 。
Make sure you upload to the Firebase console this .p12 file in the Cloud Messaging APN certificate settings. 确保您在Cloud Messaging APN证书设置中将此.p12文件上传到Firebase控制台。
Swift 4.0 迅捷4.0
Also make sure you're using: 另外,请确保您使用的是:
Messaging.messaging().setAPNSToken(deviceToken as Data, type: .prod)
inside: 内:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
#if DEVELOPMENT
//Develop
Messaging.messaging().setAPNSToken(deviceToken as Data, type: .sandbox)
#else
//Production
Messaging.messaging().setAPNSToken(deviceToken as Data, type: .prod)
#endif
}
First of all check certificate which you are exporting. 首先检查您要导出的证书。 Typical mistake is to export private key and not a service.
典型的错误是导出私钥而不是服务。 I attached a screenshot.
我附上了截图。 I hope that will save some time for you.
我希望这可以为您节省一些时间。
For me these steps resolved the same issue on production: 对我来说,这些步骤解决了生产中的相同问题:
On Apple Developer portal go to Keys - > Add key 在Apple Developer门户上,转到“密钥”->“添加密钥”
Download your key, copy Key ID parameter 下载您的密钥,复制密钥ID参数
I got it working by these steps: 我通过以下步骤使其工作:
It seems that step 4 does the difference. 看来步骤4有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.