我的应用每次尝试使用以下消息运行时都会崩溃模拟器。
函数boringssl_context_get_peer_sct_list:1757收到SCT 扩展长度小于SCT数据长度
我不确定原因,但是我希望以下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()
}
}
}