【发布时间】:2017-11-15 10:02:54
【问题描述】:
我从 Firebase Messaging API 收到此错误:
[Firebase/Messaging][I-FCM002010] Cannot subscribe to topic: /topics/testTopic with token: (null)
但之前:
Messaging.messaging().subscribe(toTopic: "/topics/testTopic")
我正在像这样打印出令牌:
print("TOKEN: \(InstanceID.instanceID().token() ?? "NO TOKEN")")
结果是:
TOKEN:cXPhGQ_inE4:APA91bEKZF5depHmIm9gDliCFRCRcnJf5LYy5FMg6nhpWvKU3o3HEtr1WTBHUiCZXT4XzhVg2oqXzhtfrgf83brtLdqXii546644ciMPO80tri4JPueQBClKbaomEfoh54ku8E2lw
所以令牌不是 null。
我做错了吗?有人帮忙吗?
【问题讨论】:
-
我也在不同的设备上进行了测试,但得到了同样的错误。
-
已解决。非常感谢!问题是我想在 didFinishLaunchingWithOptions 中订阅,但那时并没有设置所有服务。解决方案是订阅委托 didRegisterUserNotificationSettings。
-
我在 iOS 9.3.5 上看到这个 sometimes,也确认令牌存在。也从 didRegisterUserNotificationSettings 调用。
标签: ios swift firebase firebase-cloud-messaging