0

I use Firebase for sending notifications to all application users, but even Firebase shows that the message status is Complete, I'm still not getting messages in devices (using emulators).

This is my code : MyFirebaseMessagingService class :

import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

/**
 * Created by -SAMSUNG- on 06/12/2017.
 */

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        Log.d("myLog","NotificationTitle : "+remoteMessage.getNotification().getTitle());

    }
}

MyFirebaseInstanceIDService class :

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

/**
 * Created by -SAMSUNG- on 06/12/2017.
 */

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    @Override
    public void onTokenRefresh() {
        super.onTokenRefresh();

        String token = FirebaseInstanceId.getInstance().getToken();
        Log.d("myLog","Token is : "+token);

    }
}

This is the gradle :

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.github.amigold.fundapter:library:1.0'
    compile 'rongi.rotate-layout:rotate-layout:3.0.0'
    compile 'me.grantland:autofittextview:0.2.+'
    testCompile 'junit:junit:4.12'
    compile'com.google.firebase:firebase-messaging:11.6.2'
    compile 'com.google.firebase:firebase-core:11.6.2'
    compile 'com.google.maps.android:android-maps-utils:0.5+'
    compile 'com.google.android.gms:play-services:11.6.2'

}

apply plugin: 'com.google.gms.google-services'

This is the Manifest :

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logofppt"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:replace="android:icon">

    <service android:name=".MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>
    <service android:name=".MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyBOhBdH1WXX9jz9kSk8nVmoQgKaM4N0_vs" />

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.nobar" />
    <activity
        android:name=".SplashScreen"
        android:theme="@style/AppTheme.nobar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TDIinfo"
        android:label="TDI" />
    <activity
        android:name=".TCAinfo"
        android:label="TCA" />
    <activity
        android:name=".INFOGinfo"
        android:label="INFOG" />
    <activity
        android:name=".TRIinfo"
        android:label="TRI" />
    <activity android:name=".TMSIRinfo" android:label="TMSIR"/>
    <activity android:name=".TLWinfo" android:label="TLW" />
    <activity android:name=".J2EEinfo" android:label="J2EE"/>
</application>

This is the error :

D/FA: Logging event (FE): notification_receive(_nr), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-947096531520348892, message_device_time(_ndt)=0, message_time(_nmt)=1512583947, message_id(_nmid)=1882982486230769049}]
D/myLog: NotificationTitle : Emplois
V/FA: Connecting to remote service
W/GooglePlayServicesUtil: Google Play services out of date.  Requires 11720000 but found 9683470
W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
D/FA: Logging event (FE): notification_foreground(_nf), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-947096531520348892, message_device_time(_ndt)=0, message_time(_nmt)=1512583947, message_id(_nmid)=1882982486230769049}]
V/FA: Connecting to remote service
W/GooglePlayServicesUtil: Google Play services out of date.  Requires 11720000 but found 9683470
W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
V/FA: Processing queued up service tasks: 2
E/FA: Discarding data. Failed to send event to service
E/FA: Discarding data. Failed to send event to service
V/FA: Processing queued up service tasks: 0
I/art: Do partial code cache collection, code=60KB, data=50KB
I/art: After code cache collection, code=60KB, data=50KB
I/art: Increasing code cache capacity to 256KB

Please! if you have any idea how o solve this, please leave a comment..

Dev
  • 45
  • 1
  • 12

2 Answers2

0

You need to update your Google Play Services on your device

GooglePlayServicesUtil: Google Play services out of date. Requires 11720000 but found 9683470

tyczj
  • 71,600
  • 54
  • 194
  • 296
0

The problem was the emulators can't receive the notification, I have tried it with real device and it work fine ^_^

Dev
  • 45
  • 1
  • 12