Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 181 Vote(s) - 3.78 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FCM topic - Cannot subscribe to topic: xxx with token: (null) - iOS

#1
I'm getting this error from Firebase Messaging API:

[Firebase/Messaging][I-FCM002010] Cannot subscribe to topic: /topics/testTopic with token: (null)

But before:

Messaging.messaging().subscribe(toTopic: "/topics/testTopic")

I'm printing out the token like this:

print("TOKEN: \(InstanceID.instanceID().token() ?? "NO TOKEN")")

The result is:

TOKEN:cXPhGQ_inE4:APA91bEKZF5depHmIm9gDliCFRCRcnJf5LYy5FMg6nhpWvKU3o3HEtr1WTBHUiCZXT4XzhVg2oqXzhtfrgf83brtLdqXii546644ciMPO80tri4JPueQBClKbaomEfoh54ku8E2lw


So the token isn't *null*.

Am I doing something wrong? Anyone some help?
Reply

#2
I had similar problem. The solution was to invoke `FirebaseApp.configure()` first:

FirebaseApp.configure()
Messaging.messaging().delegate = self

instead of:

Messaging.messaging().delegate = self // this brakes FCM
FirebaseApp.configure()
Reply

#3
The most ideal place to resolve this issue is in the MessagingDelegate method didRefreshRegistrationToken.

func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
// TODO: subscribe to topics here
}
Reply

#4
The problem was that I wanted to subscribe in `didFinishLaunchingWithOptions` but in that point not all services were set up.
**The solution was** to subscribe in the delegate `didRegisterUserNotificationSettings`.
Reply

#5
In MessagingDelegate try it:


func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
Messaging.messaging().subscribe(toTopic: "/topics/testTopic")
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through