ios - Swift:firebase didRegisterForRemoteNotificationsWithDeviceToken 在某些设备上不起作用
问题描述
我的代码:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("Message: \(deviceToken)")
}
打开iphone 8 plus
并iphone 6
打印设备令牌但iphone 6s
不起作用
iphone 8 plus
和iphone 6s
版本是11.4
结果iphone 8 plus
并iphone 6
收到通知但未iphone 6s
收到
我的代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
if((Messaging.messaging().fcmToken) != nil){
AppDelegate.USERTOKEN = (Messaging.messaging().fcmToken)!
}
print("Message APP: \(AppDelegate.USERTOKEN)")
return true
}
注意:print("Message APP: \(AppDelegate.USERTOKEN)")
适用于所有设备并打印令牌。
解决方案
推荐阅读
- c++ - 将 C++ Dll 加载到 vb.net 应用程序中
- error-handling - HTTP 错误 403:禁止访问:访问被拒绝
- mysql - 如何在 sequelize 中执行事务和回滚?
- node.js - 为什么函数从 AtlasDB 返回 false 而对于我的本地版本返回 true
- c# - 如何简单地创建一个 Linq 表达式集合作为参数?
- javascript - Javascript数组以逗号而不是名称开头?
- r - 如何在 R Shiny 小部件包的状态栏中添加金钱前缀?
- ckeditor - 如何在您的应用程序中真正使用 RTE(富文本编辑器)?
- kotlin - SynchronossFormFieldPart 无法转换为 FilePart
- javascript - 从 PHP 文件访问脚本标签内的变量