我已经确认,在从Xcode加载构建时,我可以接收从云功能和firebase控制台发起的通知.
我引用了其他类似的问题,但没有一个反映出我正在处理的确切问题.在Firebase中配置远程通知时,我使用的是APNs Auth Key,我还为开发和生产提供了两个.p12文件.但是,.p12文件显示为灰色并列为非活动状态,因为已设置APNs验证密钥.
在我的Apple开发人员帐户下的证书,标识符和配置文件,我已确保我的APNs Auth Key存在于左侧的Keys部分.我还在我的App Id&中设置了开发人员和生产SSL证书.验证它们被列为“已启用”.我还验证了我有一个“活动”的iOS Distribution Provisioning Profile.
这是一个难以调试的问题,因为Xcode构建工作但TestFlight构建却没有.我知道这个问题涉及生产与开发环境,但我不确定如何解决问题.
在Xcode构建中调用此方法,并且所有相关的UserNotifications&正在调用消息传递委托方法.我正在运行iOS 10.3&在我的info.plist中将FirebaseAppDelegateProxyEnabled设置为NO.
func application(_ application: UIApplication,didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Messaging.messaging().setAPNSToken(deviceToken,type: MessagingAPNSTokenType.sandBox) Messaging.messaging().setAPNSToken(deviceToken,type: MessagingAPNSTokenType.prod) }
解决方法
Messaging.messaging().setAPNSToken(deviceToken,type: .unknown)
在以前的应用程序中,我使用了:
if Config.isDebug { tokenType = MessagingAPNSTokenType.sandBox } else { tokenType = MessagingAPNSTokenType.prod } Messaging.messaging().setAPNSToken(deviceToken,type: tokenType)
并设置Config以依赖Xcode中的构建方案.现在似乎没有在prod工作.在Firebase上,我现在使用的是APNS Key,而不是旧式的Prod和Dev证书.这可能有所不同.我看到Firebase docs现在也说:
If the token type is set to UNKNOWN Firebase Messaging will implicitly try to figure out what the actual token type is from the provisioning profile. Unless you really need to specify the type,you should use the APNSToken property instead.