I'm using FirebaseMessagingService for receiving data from Firebase and I need to open an activity to show that data
Just like skype when new call is come.
It's getting the new message and triggers startActivity on Foreground but not in background.
This is my service:
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onNewToken(p0: String) {
super.onNewToken(p0)
}
override fun onMessageReceived(p0: RemoteMessage) {
super.onMessageReceived(p0)
val data: Map<String, String> = p0.data
if (data.isNotEmpty()) {
Log.i(TAG, "onMessageReceived: $data")
val dialogIntent = Intent(this, LocationTrackingActivity::class.java)
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK )
application.startActivity(dialogIntent)
}
}
}
I've granted SYSTEM_ALERT_WINDOW permission and checked it from settings to assure it's enabled.