gpt4 book ai didi

ios - 在 XCode 9 中的 IOS 上使用 Firebase 消息传递

转载 作者:行者123 更新时间:2023-11-30 11:58:19 25 4
gpt4 key购买 nike

每次我尝试运行时,我的应用程序都会使模拟器崩溃,并显示以下消息。

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/

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