Sajid Kalla
Sajid Kalla

Reputation: 199

Firebase Cloud Messaging and multiple topic subscription from iOS fails

I am getting an error when calling subscribeToTopic in iOS,

Failed to subscribe to topic Error Domain=com.google.fcm Code=5 "(null)"

There are 3-4 topics and we call like below, which is pretty basic..

    for topic in topics{
        FIRMessaging.messaging().subscribeToTopic(topic)
    }

Documentation says that the call is asynchronous and if subscription failed, firebase will retry. But it continued to fail and the user never receives any message sent to that topic.

Anyone facing this issue and found a solution?

Upvotes: 14

Views: 9241

Answers (2)

mabg
mabg

Reputation: 2092

I've added in URL Types com.google.fcm and the error dissappears, I don't know why.

You can see like to add in this link

Upvotes: 0

Daniel Kuta
Daniel Kuta

Reputation: 1634

I had the same error. Add this to your AppDelegate:

    func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    FIRMessaging.messaging().subscribeToTopic("/topics/yourTopic")

}

and remember to call FIRApp.configure() in didFinishLaunchingWithOptions method.

Upvotes: 3

Related Questions