2

In All condition i am getting notification fine but in below android 6.0 not getting notification only if when app killed

here is my receiver's method

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    if (remoteMessage.getData().size() > 0) {
        Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
        try {
            params = remoteMessage.getData();
            Log.e(TAG, "FCM data: " + new JSONObject(params).toString());
            JSONObject json =new JSONObject(params);
            handleDataMessage(json);
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }

//here is manifest.xml

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

1 Answers1

0

Not sure its relevant or not but I'm now using data payload instead of notification payload and handle the data's included in notification personally. This way the notification received will always work as how we wanted it to work instead of default FCM way of handling notification which will show notification at system tray with notification payload's head and body. This may fixed the issue of your app receiving notification only when in foreground.

Check this out Push notification works incorrectly when app is on background or not running

https://github.com/firebase/quickstart-android/issues/41

Lakshmi
  • 78
  • 11
  • thank you for your answer but I am already using data key to send notification.It is working fine in android 6.0 and above but in below 6.0 i am not getting notification only if when app killed. – Akshay dashore Jun 21 '18 at 06:17
  • Did you check the last four Post (IgniteCoders) in the GitHub link which i have mentioned. – Lakshmi Jun 21 '18 at 06:53
  • yes i have checked and i got solution it was an device specific issue .Notification are not coming in some devices like vibe K5 and vivo y3l but it is working fine in moto e with android 5.0. thank you for contribution. – Akshay dashore Jun 21 '18 at 07:11