gpt4 book ai didi

ios - 使用带有 APNs 授权 key 的 Firebase 的生产推送通知

转载 作者:可可西里 更新时间:2023-11-01 06:13:14 26 4
gpt4 key购买 nike

在 TestFlight 上测试我的应用程序时,我注意到我没有收到推送通知。

我已经确认,在从 Xcode 加载构建时,我可以收到来自云函数和 firebase 控制台的通知。

我引用了其他类似的问题,但没有一个能准确反射(reflect)我正在处理的问题。在 Firebase 中配置远程通知时,我使用的是 APNs Auth Key,我还包含了用于开发和生产的 .p12 文件。但是,.p12 文件变灰并列为非事件文件,因为已设置 APNs 授权 key 。

在我的 Apple Developer 帐户的Certificates, Identifiers & Profiles 下,我已确保我的 APNs Auth Key 存在于左侧的Keys 部分。我还在我的应用程序 ID 中设置了开发人员和生产 SSL 证书,并验证它们是否被列为“已启用”。我还验证了我有一个“有效”的 iOS 分发配置文件。

这是一个很难调试的问题,因为 Xcode 构建可以工作,但 TestFlight 构建不能。我知道这个问题涉及生产环境与开发环境,但我不确定如何解决这个问题。

此方法在 Xcode 构建中被调用,所有相关的 UserNotificationsMessaging 委托(delegate)方法都被调用。我运行的是 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)
}

最佳答案

我的解决方法是停止使用 MessagingAPNSTokenType.sandbox 或 .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 中的构建方案。现在它似乎不适用于产品。在 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.

关于ios - 使用带有 APNs 授权 key 的 Firebase 的生产推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44446527/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com