start activity from FCM when the Application is dead?

fcm app background
push notification not received when app is closed in android firebase
handle fcm push notification when app is not running android
fcm collapse_key
fcm broadcast receiver
android custom notification when app is in background
how to handle notification when app in background in firebase ios
fcm sender id

I am using Firebase Cloud Messaging and want to display a call. The firebase message is received successfully and the notification part works but i am unable to launch the ShowCallActivity from inside my FirebaseMessagingService when the application has been closed and is DEAD

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    if(remoteMessage.getNotification().getBody().equals("showcall")) {
            Log.e(TAG,"Want to start activity");
            Intent intent = new Intent(this,ShowCallActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            sendNotification(remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody());
        }
    }

}
// 

The notification is shown but it won't open the dead application.

I'm new in programming and finally found a little clue about this problem. The new version of android (MarshMallow) has a new restriction that restricts activity to be opened from the app when the app is dead. I can't explain much but you can read here https://developer.android.com/guide/components/activities/background-starts?authuser=1 Every intent works well if this permission is granted. You could check on any VOIP app like WhatsApp. the app already granted this permission without the user knowing. hope this help

onMessageRecieved not working when app is killed. · Issue #368 , But when app is killed I receive notification and after click on it- Extras == null. getActivity(this, 0 /* Request code */, intent, PendingIntent. FCM does not process messages if an app is "killed" or force stopped. does not want the app running so that app should not run till the user explicitly starts it again. Android Push Notification using Firebase Cloud Messaging ( FCM ) , works in Foreground , background , app killed, dead. includes Notification Actions - Abhishek Garg - AndroidManifest.xml

I order to make it work I had to use a data message and keep the "notification" key empty.

Example from firebase docs.

{
    "message":{
        "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
        "data":{
             "Nick" : "Mario",
             "body" : "great match!",
             "Room" : "PortugalVSDenmark"
        }
     }
}

How properly receive messages when app is killed? · Issue #272 , In general, starting a foreground activity from a service is pretty bad from then FCM will by default launch your application with the appropriate  The FCM works fine when the app is in foreground and a push comes, but when the app is in background and the system tray notification is clicked , it just opens up the app without passing any intent extras. I have added the click_action in Notification Payload from Advanced option of Firebase Console to open an activity but it dosen't work. I have also added the intent-filter ( handle backgound app section) as in documentation.

Intent resultIntent = new Intent(this, MainActivity.class);
        resultIntent.putExtra("msg", name);
        PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0,
                resultIntent, PendingIntent.FLAG_ONE_SHOT);

Use this inside your send notification and replace the MainActivity with the class you want to open

firebase-cloud-messaging, firebase-cloud-messaging documentation: Message handling with app in Firebase handles notifications differently when the app is in background (killed process) and when in foreground (active). Instead, the the click will open the activity from the Manifest.xml marked with: source 1: FCM background handling​. Btw, I just learnt in last few day we should not use a service with START_STICKY to start the FCM service because FCM service is an IntentService which will automatically start its own when needed and stop itself when finished.

How to handle notification when app in background in Firebase , If the application is in the foreground handle both data and notification messages here. as a result of a received FCM // message, here is where that should be initiated. be able to handle the message in onMessageReceived, even if in background or killed. putExtra("value", value); //startActivity(intent); //finish(); txtMsg. This happens because once your application is force closed, it gets put into a "stopped state". A stopped state in short will not accept broadcast intents.

Handling FCM notifications with notification payload, when the app , Handling FCM notifications with notification payload, when the app is in and as it says to handle notifications when the app is killed or in background, to receive the FCM messages and explicitly pulling out the intent filters  DanikKamilov commented Nov 4, 2017. onMessageRecieved not working when app is killed. It works perfect in foreground and in background and I can receive Extras in MainActivity. But when app is killed I receive notification and after click on it- Extras == null.

Android app not receiving Firebase Notification when app is , Android app not receiving Firebase Notification when app is stopped or killed by DefaultOrderedBroadcastReceiver will start this service to send notifications to activity when app is not is memory or in background after receiving from FCM  Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost. Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can

Comments
  • Have you solved this problem yet?
  • stackoverflow.com/a/51860819/5841416 It can be solved from the sever side.
  • This will tirgger the onMessageReceived callback.
  • That is already working. What i want is a call to be made. As during a call no notification needs to be clicked.
  • stackoverflow.com/questions/37554274/…