im referring this answer for foreground and background to receive firebase notification --> https://stackoverflow.com/a/38451582/12553303
actually following is my doubt:----------
what if i didnt code for foreground condition(talking about push notification) still i will get notifcation when my app is in background right????-->yes
but when im on foreground state and i pushed a notification from firebase -->i wont see notification on status bar that is also okay(beacuse suppose i didnt override onmessagereceive() method)....then next i go to background state i didnt see any notification though which i sent for background
what should i do to get notification which i sent for background like going from foreground state(with no method of onmessagereceived()) to background state??*
thanks need advice and clarification on this ...
is this even possible get that notification moving from foreground state to background state??
code :----
override fun onMessageReceived(p0: RemoteMessage) {
super.onMessageReceived(p0)
Log.d("msg", "onMessageReceived: " + p0.getData().get("message"))
val intent = Intent(this, OrderListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)
val channelId = "Default"
val builder: NotificationCompat.Builder =NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(p0.getNotification()?.getTitle())
.setContentText(p0.getNotification()?.getBody()).setAutoCancel(true)
.setContentIntent(pendingIntent)
val manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelId,
"Default channel",
NotificationManager.IMPORTANCE_DEFAULT)
manager.createNotificationChannel(channel)
}
manager.notify(0, builder.build())
}
any advice will be appreciated thanks