0
votes

I have followed the firebase documentation cloud messaging for android https://firebase.google.com/docs/android/setup

Followed these steps :

  1. Created project on firebase
  2. downloaded google-services.json and added it in project
  3. Added below services in manifest file : MyFirebaseInstanceIDService

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

    MyFirebaseMessagingService

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

  4. Added meta data in manifest file :

    <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_launcher" />
            <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorAccent" />
    
  5. I am getting the registration token through

    FirebaseInstanceId.getInstance().getToken()

and also added onRefreshToken()

Still I am not getting the notification from firebase console.

2
One more thing, just make sure your device Date and Time is correct! - Dhruv Kaushal

2 Answers

0
votes

In your MyFirebaseMessagingService, does the method onMessageReceived(RemoteMessage remoteMessage) getting called when you try to send the push?

If so, you need to use the NotificationCompat.Builder to build the notification and then notify the OS to create the notification.

You can read the docs here: https://developer.android.com/training/notify-user/build-notification.html

0
votes

Just removed tools:node="replace" from application tag in AndroidManifest.xml file and notification is working fine now. There was no issue of fiebase implementation.