1

I have made the switch from GCM to FCM in my android app. But I have not touched the server portion of the code since supposedly I don’t have to. But now, when server sends a notification, my device is no longer seeing it. So did I misunderstand the following?

https://developers.google.com/cloud-messaging/android/android-migrate-fcm#update_server_endpoints

Updating these endpoints is not strictly required, as Google will continue to support the existing GCM endpoints.

MANIFEST

<!-- for notifications -->
    <!--<uses-permission android:name="android.permission.WAKE_LOCK"/>-->
    <!--<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>-->
    <!--<uses-permission android:name="com.business.myapp.android.permission.C2D_MESSAGE"/>-->

…

<application …>

…
<!-- START GCM SECTION -->
        <!--<receiver-->
            <!--android:name="com.google.android.gms.gcm.GcmReceiver"-->
            <!--android:exported="true"-->
            <!--android:permission="com.google.android.c2dm.permission.SEND">-->
            <!--<intent-filter>-->
                <!--<action android:name="com.google.android.c2dm.intent.RECEIVE"/>-->

                <!--<category android:name="com.business.myapp"/>-->
            <!--</intent-filter>-->
        <!--</receiver>-->

        <service
            android:name=".data.service.notification.BusinessGcmListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service
            android:name=".data.service.notification.BusinessInstanceIDListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
        <service
            android:name=".data.service.notification.RegistrationIntentService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            </intent-filter>
        </service>
        <!-- END GCM SECTION -->

Note that when I send notification from the Firebase Console it comes through: if the app is in the foreground, it goes through onMessageReceived; otherwise, I just get a notification in status bar. Basically I follow the instructions on the link provided.

Here is onTokenRefresh

@Override
public void onTokenRefresh() {
    Intent intent = new Intent(this, RegistrationIntentService.class);
    startService(intent);//intent service to send token to my server
}
Nouvel Travay
  • 6,292
  • 13
  • 40
  • 65
  • So I followed all the instructions on that page. Except the server has not been changed (another team would have to do it); also the note says I don't need to change the server. – Nouvel Travay May 26 '16 at 22:57
  • Did you create a new Firebase project as part of this at all? Or was it an upgrade from your existing Google project? – Ian Barber May 27 '16 at 02:08
  • No new project. I just use my existing project. – Nouvel Travay May 27 '16 at 18:42
  • Could you include a snippet of your FCM implementation on the client and the relevant parts of the manifest? The issue may be there. – Ian Barber May 27 '16 at 22:48
  • I have added the manifest data and some. I just followed the step by step they provide see link https://developers.google.com/cloud-messaging/android/android-migrate-fcm#import_your_gcm_project_as_a_firebase_project – Nouvel Travay May 28 '16 at 00:38
  • Just to check - GCM sender ID you were using before - does that match the project number value in the google-services.json? – Ian Barber Jun 03 '16 at 05:14

1 Answers1

0

Do you change your json-service.json of on root /app of on application ?