每次我尝试运行时,我的应用程序都会使模拟器崩溃,并显示以下消息。
Function boringssl_context_get_peer_sct_list: line 1757 received sct extension length is less than sct data length
我不确定原因,但我希望获得有关以下 3 行正确顺序的反馈:
FirebaseApp.configure()
Messaging.messaging().delegate = self
// IOS 9
application.registerForRemoteNotifications()
或
// IOS10
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge])
UIApplication.shared.registerForRemoteNotifications()
最佳答案
这是最好的方法。
先请求许可,获得批准后,再注册推送通知
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
print("permision granted \(granted)")
guard granted else { return }
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
print("Notification Settings \(settings)")
guard settings.authorizationStatus == .authorized else { return }
DispatchQueue.main.async {
// register
UIApplication.shared.registerForRemoteNotifications()
}
}
}
关于ios - 在 XCode 9 中的 IOS 上使用 Firebase 消息传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47543485/