0

I've a calling app in which I'm working with real time calling with fcm. I'm able to send and receive call when app is live and in background by taking permission for battery optimisation. Problem is when the app is killed or remove from recent app list I am getting onReceivedMessage of fcm called but how should I start my activity to show incoming call to the second user. Please help me on this.

Below is my onMessageReceived code:

 public void onMessageReceived(@NonNull RemoteMessage message) {
        super.onMessageReceived(message);

        String type = message.getData().get(Constants.REMOTE_MSG_TYPE);
        Log.d(TAG, "onMessageReceived: "+message.getData());
        if (type != null) {
            if (type.equals(Constants.REMOTE_MSG_INVITATION)) {
                Intent intent = new Intent(getApplicationContext(), IncomingInvitation.class);
                intent.putExtra(Constants.REMOTE_MESSAGE_MEETING_TYPE, message.getData().get(Constants.REMOTE_MESSAGE_MEETING_TYPE));
                intent.putExtra(Constants.name, message.getData().get(Constants.name));
                intent.putExtra(Constants.REMOTE_MESSAGE_INVITER_TOKEN, message.getData().get(Constants.REMOTE_MESSAGE_INVITER_TOKEN));
                intent.putExtra(Constants.REMOTE_MSG_MEETING_ROOM, message.getData().get(Constants.REMOTE_MSG_MEETING_ROOM));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            } else if (type.equals(Constants.REMOTE_MSG_INVITATION_RESPONSE)) {
                Intent intent = new Intent(Constants.REMOTE_MSG_INVITATION_RESPONSE);
                intent.putExtra(Constants.REMOTE_MSG_INVITATION_RESPONSE, message.getData().get(Constants.REMOTE_MSG_INVITATION_RESPONSE));
                LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
            }
        }
    }

As discussed above I'm getting calls when app is alive or in background but not when app is killed or remove from memory. I want to start app when a call received when the app is not in the memory.

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
Md Shadab
  • 1
  • 1

0 Answers0