I try to make gcm work.
When our server sends a push notification I got these two errors in my app\'s log:
E/GcmReceiver(8049
Adding firebase messaging dependency worked for me
implementation 'com.google.firebase:firebase-analytics:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
Please note that firebase-messaging have a dependency on firebase-analytics
just check gradle for required updated and then sync you app and run again that's worked for (maybe something wrong in firebase)
You should have these 3 services in your manifest. You're missing the one with the action com.google.android.c2dm.intent.RECEIVE
<service
android:name="com.myapppackage.application.gcm.GcmIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.myapppackage.application.gcm.GcmIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="com.myapppackage.application.gcm.RegistrationIntentService"
android:exported="false"/>
Hey You need to add MyGcmListenerService class for receive notification:
public class MyGcmListenerService extends GcmListenerService {
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
}
you need add this class as service in AndroidMaifest.xml
<service android:name="com.mypackage.application.services.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>