3

I've been using GCM service to send notification to my existing App, in PHP server, as per https://stackoverflow.com/a/11253231/3286489.

Now I'm thinking of migrating to FCM. As per noted https://stackoverflow.com/a/37517339/3286489, the notification service URL "https://android.googleapis.com/gcm/send" has been changed to "https://fcm.googleapis.com/fcm/send"

As I'm still newly explore the FCM, I hope my question is not dump. I have two questions here.

1.) Once migrated to FCM in my client, can I still use back the same PHP code that send my GCM as per https://stackoverflow.com/a/11253231/3286489? Or could I just change the API URL (to fcm.googleapis.com) but retain all PHP code the same? (i.e. is 'https://fcm.googleapis.com/fcm/send' backward compatible with 'https://android.googleapis.com/gcm/send'?)

2.) Upon migrated to FCM (on the server push), and even when after I have upgraded my App to use FCM instead of GCM, I believe there will still be some user that's stick to the older App for a while using GCM. When I send push notification out, do I need to send to both FCM and GCM separately (i.e. I need to keep the old GCM server code for a while)? or I just need to send the FCM, and my old App (with only GCM) will still receive it?

I hope the answer is yes for both, but feel like not likely it's yes. So write to confirm my understanding.

Community
  • 1
  • 1
Elye
  • 30,821
  • 26
  • 115
  • 272
  • Have you seen the [migration guide](https://developers.google.com/cloud-messaging/android/android-migrate-fcm)? – Waclock Mar 08 '17 at 13:24
  • Yes, I have read that, and use that to migrate my GCM. I didn't find anything on the Server side of code though. – Elye Mar 08 '17 at 21:49

1 Answers1

3

The answer to both is Yes.

For #1, my post that you linked pretty much answers it. So just to confirm, using the FCM endpoint to send towards your GCM users should be fine. It's still compatible.

For #2, no need to send separate payload for GCM users. As I said above, it is backwards compatible.

Community
  • 1
  • 1
AL.
  • 33,241
  • 9
  • 119
  • 257
  • @Elye Did this answer your question? Or were you looking for something different? – AL. Mar 10 '17 at 08:35
  • 1
    Sorry, haven't have time to tried them out. After trying, work like a charm. I also notice that I use GCM server side send the notification, the FCM client can also get it, and vice versa. Seems like fully compatible. – Elye Mar 13 '17 at 12:39
  • I have not been able to successfully send a message from my FCM project to my GCM client. I am not sure if some changes need to be made here. – pranavrao1 Oct 31 '17 at 18:17
  • > For #2, no need to send separate payload for GCM users. As I said above, it is backwards compatible. < This statement is not correct. Users created with GCM client are not getting messages from FCM server. FCM endpoint is failing with error: `MismatchSenderId`. – engin Sep 17 '18 at 23:32
  • @engin You have to keep use the same sender Id used to generate tokens in GCM to send to it. `MismatchSenderId` error occurs when you're attempting to send to a token using a sender id not associated with it. I've tested sending to a GCM and FCM token from the same sender and it works. – AL. Sep 18 '18 at 02:46
  • Thanks for responding @AL. Do you know what does it mean to `create a mapping between old GCM tokens and the Firebase project.` ? Which is mentioned in this page https://developers.google.com/cloud-messaging/android/android-migrate-firebase-project – engin Sep 20 '18 at 17:18