Почему imgsGroupId из MyFirebaseMessagingService.kt с использованием Intent.putExtra trasmit в MainActivity.kt стал другим imgsGroupId ???
logcat:
MyFirebaseMessagingService.kt
21
class MyFirebaseMessagingService : FirebaseMessagingService() {
private val TAG: String? = MyFirebaseMessagingService::class.java.simpleName
@RequiresApi(Build.VERSION_CODES.O)
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
Log.d(TAG, "onMessageReceived: remoteMessage = $remoteMessage")
val imgsGroupId = remoteMessage.data["imgsGroupId"]
Log.d(TAG, "onMessageReceived: imgsGroupId = $imgsGroupId")
val notificationContent = remoteMessage.data["messageContent"]
val userName = remoteMessage.data["userName"]
Log.d(TAG, "onMessageReceived: userName = $userName")
val userAvatarUrl = remoteMessage.data["userAvatarUrl"]
val inputStream = URL(userAvatarUrl).openStream()
val userAvatarBitmap = BitmapFactory.decodeStream(inputStream)
createNotificationChannel()
val intent = Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
putExtra("imgsGroupId",imgsGroupId)
}
val pendingIntent = PendingIntent.getActivity(
this, 0,
intent,
0
)
val notification = NotificationCompat.Builder(this, MESSAGE_NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_baseline_message_24)
.setContentTitle(userName)
.setContentText(notificationContent)
.setLargeIcon(userAvatarBitmap)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build()
with(NotificationManagerCompat.from(applicationContext)) {
notify(MESSAGE_NOTIFICATION_ID, notification)
}
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notificationChannel = NotificationChannel(
MESSAGE_NOTIFICATION_CHANNEL_ID,
MESSAGE_CHANNEL_NAME,
NotificationManager.IMPORTANCE_HIGH
).apply {
enableLights(true)
lightColor = Color.CYAN
}
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(notificationChannel)
}
}
override fun onNewToken(token: String) {
super.onNewToken(token)
}
}
MainActiveService.kt *1019* 21 *1020* 1023 *