14

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?

Sajid Kalla
  • 189
  • 5
  • 13
  • it works when we add delay in between the calls, that means there is a problem in multiple subscribeToTopic calls in a loop.. I guess it is a common scenario to subscribe to multiple topics – Sajid Kalla May 22 '16 at 14:29
  • I think even if it fails initially it will certainly retry after some delay to sync the state between the client and the server. – evanescent Jun 02 '16 at 00:06
  • It's fine if the retry happens at FCM server side. If the sdk saves failed subscriptions in the device to sync in future, will be a problem. We do not expect the user to re-open the app for push subscriptions.. :) – Sajid Kalla Jun 02 '16 at 02:52

2 Answers2

3

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.

Daniel Kuta
  • 1,634
  • 15
  • 24
0

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

Community
  • 1
  • 1
mabg
  • 1,894
  • 21
  • 28