I am using webRTC to implement one-to-one audio and video calls in my app. I have made a calling activity with an accepting and decline button which appears whenever a call is coming for that device token. I am using FirebaseMessagingService and ChildEventListener to load that calling activity. All works fine whenever the app is running but the activity doesn't show up when the app is killed. How can I show it in the background too just like it is done on WhatsApp? Here is my code :
My FirebaseMessagingService Class:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (!done){
if (remoteMessage.getData().size() > 0) {
Intent intent = new Intent(MyFirebaseMessagingService.this, IncomingCallActivity.class);
intent.putExtra("message", remoteMessage.getNotification().getBody());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
done=true;
}
}
if (!done){
if (remoteMessage.getNotification()!=null){
Intent intent = new Intent(MyFirebaseMessagingService.this, IncomingCallActivity.class);
intent.putExtra("message", remoteMessage.getNotification().getBody());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
done=true;
}
}
}
Any tips or guidance will be helpful.