7

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>
Anmol
  • 344
  • 4
  • 18
  • 1
    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](https://developers.google.com/cloud-messaging/android/android-migrate-fcm). If you need firther details, just look around the official docs. Pretty sure you'll find what you need there. – AL. Jun 25 '16 at 06:52
  • 1
    @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 Jun 25 '16 at 10:12
  • What were you using to generate the old tokens? The Firebase console will only work with InstanceID tokens. – Arthur Thompson Jun 25 '16 at 16:42
  • @ArthurThompson I'm using InstanceID only to generate gcm registration tokens. – Anmol Jun 25 '16 at 19:56
  • Once you are using InstanceID to generate your tokens that you can use FCM to send messages to all of your clients. Both GCM and FCM use InstanceID tokens so from the API or Firebase console there is no distinction between the clients. – Arthur Thompson Jun 25 '16 at 23:37
  • 1
    @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 Jun 26 '16 at 09:17
  • Are your FCM and GCM tokens associated with the same project? – Arthur Thompson Jun 26 '16 at 21:21
  • Yes, obviously they are. – Anmol Jun 27 '16 at 09:24

4 Answers4

1

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.

Community
  • 1
  • 1
KENdi
  • 7,205
  • 2
  • 14
  • 26
  • 1
    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 Jun 25 '16 at 10:10
1

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.

Anmol
  • 344
  • 4
  • 18
  • So did you have both GCM and FCM implementations in your App? Is that working for you? – Marie Amida Jan 13 '17 at 09:52
  • @MarieAmida Users with old versions have gcm in the App and the New Users have fcm. So, now what I'm doing is sending push to tokens using both fcm & gcm server side implementation. Also, It's working great for me. – Anmol Jan 13 '17 at 13:14
0

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))"

RED.Skull
  • 1,388
  • 1
  • 18
  • 43
-1

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/

Nilesh Deokar
  • 2,777
  • 27
  • 47