Я не могу передать значение из push-уведомления в действие
Я использую Firebase Messaging Service для push-уведомлений. Но я не могу передать значение деятельности, используя PendingIntent.
MyFirebaseMessagingService
val intent = Intent(this, MainActivity::class.java)
intent.putExtra("key", "value")
val contentIntent = PendingIntent.getActivity(
this, 0, intent, 0)
notificationBuilder.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.sa_logo_mini)
.setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.sa_icon_big))
.setContentTitle(title)
.setContentText(content)
.setContentIntent(contentIntent)
.setContentInfo("Breaking")
notificationManager.notify(1, notificationBuilder.build())
MainActivity
val Y = intent.getStringExtra("key")
Log.i(C.T, "CHECHE = "+Y)
После нажатия на push-уведомление запускается MainActivity, но intent.getStringExtra ("key") всегда равно нулю.
Где ошибка?