[英]Push notifications doesn't work on TestFlight
I use Firebase to send notifications: 我使用Firebase发送通知:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
let pushNotificationSettings = UIUserNotificationSettings(types: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
UIApplication.shared.applicationIconBadgeNumber = 0
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print("MessageID : \(userInfo["gcm_message_id"]!)")
print (userInfo)
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type:FIRInstanceIDAPNSTokenType.sandbox)
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type:FIRInstanceIDAPNSTokenType.prod)
}
I uploaded on Firebase two certificates: "APNs Development iOS" as development cert. 我在Firebase上上传了两个证书:“ APNs Development iOS”作为开发证书。 and "Apple Push Services" as distribution (production) cert.: 和“ Apple Push Services”作为分发(生产)证书:
I get notifications in development mode, but I didn't get notifications when I downloaded my app at TestFlight. 我在开发模式下收到通知,但是在TestFlight下载我的应用程序时没有收到通知。
I removed sertificates and created new certificates and uploaded them again. 我删除了证书并创建了新证书,然后再次上传。 Now it works. 现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.