7
votes

I want to migrate from gcm to fcm in android app. Do I need to send push notification to old users of the android app from gcm or i can send it through the new fcm from server?

FCM is working fine I'm able to receive push notifications on my device through fcm but I'm not able to send push notifications to old GCM registration tokens from FCM console.


Below is the code I've added to my manifest file for fcm to work-

<uses-permission android:name="com.google.android.z.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application>
    <service
        android:name=".view.activity.MyFcmListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <service
        android:name=".view.activity.MyInstanceIDListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
</application>
4
Once you migrate your project from GCM to FCM, you'll be able to send like usual through fcm. Though there are migration steps to follow. Check some of it here. If you need firther details, just look around the official docs. Pretty sure you'll find what you need there. - AL.
@intj I've already migrated and the new fcm configuration is working fine. But my concern is I'm not able to send push notification to the GCM registration tokens. When I try sending the push to old gcm registration token through Firebase Console it fails. Can you give any input on that? - Anmol
What were you using to generate the old tokens? The Firebase console will only work with InstanceID tokens. - Arthur Thompson
@ArthurThompson I'm using InstanceID only to generate gcm registration tokens. - Anmol
@ArthurThompson I'm able to send push to FCM reg. tokens only but when i enter any GCM reg. token in firebase notification console It says "Failed". - Anmol

4 Answers

1
votes

I think you can send it through FCM. To know more about FCM you can check the documentation for frequently asked questions about GCM to FCM. Also if you are starting to migrate from GCM to FCM the you can follow this tutorials:

Also for more information, you can check this SO question.

1
votes

I searched a lot but couldn't find a satisfactory answer. So, I applied this fix.

I am continuing using the old method I was using to send push notifications to GCM users and for the users who registers through FCM, I am able to send them push notifications through FCM or Firebase Notification console.

P.S. You can't send push notification to GCM registration tokens through FCM.

0
votes

I have done POC on this same scenario, and what i observed is given below

"There is no code change require from client side when you trying to migrate GCM to FCM, and i have tested in both Android and iOS it's working fine. Only change require to do proper configuration in FCM console (i.e give correct bundle id and project id (senderid))"

-1
votes

Actually it does work FCM and GCM are the under same hood. A token for GCM works for FCM as well.

GCM tokens retrieved via GoogleCloudMessaging.register() or InstanceID.getToken() will continue to work in FCM without any modification or renewal.

All you need to do is change your client side implementation as mentioned here. and update your server endpoint to fcm.googleapis.com/fcm/