我使用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)
}
我在Firebase上传了两个证书:“APNs Development iOS”作为开发证书。和“Apple推送服务”作为发行(生产)证书。:
我在开发模式下收到通知,但是当我在TestFlight下载我的应用时,我没有收到通知。
答案 0 :(得分:0)
我删除了sertificates并创建了新证书并再次上传。现在它有效。