Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 822
Sajid Kalla Avatar asked May 22 '16 09:05

Sajid Kalla


1 Answers

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.

like image 130
Daniel Kuta Avatar answered Sep 20 '22 09:09

Daniel Kuta