0

I am migrating from GCM to FCM. Before we were sending messages to thousands of devices based on a collection of GCM tokens stored on our servers. Now with FCM we are supposed to use topics. This works nicely for FCM generated tokens, but it does not work for old GCM tokens. Can someone confirm that this is the case?

I get a strange error when trying to send a message with an old gcm token. "An error occurred when trying to authenticate to the FCM servers". It looks like an error message bug, because we don't have authentication issues when we use new FCM tokens.

If old tokens are not supported, how do we successfully migrate then?

code i am executing:

        admin.initializeApp({
            credential: admin.credential.cert(serviceAccount),
            databaseURL: "https://admob-app-id-3193292840.firebaseio.com"
        });

        var registrationTokens = [token];

        var topic = "test_1234";

        var message = {
            topic : topic,
            data: {'message':JSON.stringify(data)},
            android: {
                ttl: 36000 * 1000,
                priority: 'normal',
                collapseKey: "fcm"
            }
        };

        var dryRun = false;

        admin.messaging().subscribeToTopic(registrationTokens, topic)
            .then(function(response) {
                console.log(JSON.stringify(response));

            })
            .catch(function(error) {
                console.log('Error subscribing to topic:', error);
        });
Gillis Haasnoot
  • 2,229
  • 1
  • 19
  • 23
  • i think it's an bug. see the possibles https://github.com/firebase/firebase-functions/issues/183 – Masoom Badi May 16 '18 at 11:44
  • Hey Gillis. AFAIK, using the GCM tokens for Firebase is fine and everything should work just like it was during GCM days. It's hard to tell where the issue could be, if we don't see any code or screenshot of where this error is showing up. How are you sending the message? Did you import the GCM project to the Firebase Console? As it currently stands, your post would probably be voted as *off-topic -- why isn't this code working?* – AL. May 16 '18 at 13:41
  • I have added code to my question – Gillis Haasnoot May 16 '18 at 18:48
  • You cannot use GCM tokens in Firebase. I have tested it. it just won't accept the token. Maybe there are different versions of GCM tokens? I am in this case talking about clients still relying on old GCM implementation. – Gillis Haasnoot May 23 '18 at 13:05

0 Answers0