Я получаю уведомление при получении сообщения pu sh в android. Поэтому я написал так же, как этот URL . но я не вижу поле заголовка уведомления. как я могу исправить этот код? Я вижу маленький значок в строке состояния, но не вижу заголовка
манифест
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
FirebaseService
class FirebaseMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
Log.d("TAG", "Refreshed token: $token")
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
Log.d("TAG", "From: " + remoteMessage.from!!)
val messageBody = remoteMessage.notification?.body
val messageTitle = remoteMessage.notification?.title
val intent = Intent(this, LoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT)
val channelId ="1000"
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val inboxStyle = NotificationCompat.InboxStyle()
val notificationBuilder = NotificationCompat.Builder(this,channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(messageTitle)
.setContentText(messageBody)
.setAutoCancel(true)
.setOngoing(true)
.setSound(defaultSoundUri)
//.setContentIntent(pendingIntent)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.haii))
.setColor(getResources().getColor(R.color.colorPrimary))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setStyle(inboxStyle)
.setFullScreenIntent(pendingIntent,true)
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
val channelName ="Channel Name"
val channel = NotificationChannel(channelId,channelName,NotificationManager.IMPORTANCE_HIGH)
channel.enableLights(true)
channel.lightColor= 0x00FFFF
channel.setShowBadge(false)
notificationManager.createNotificationChannel(channel)
}
notificationManager.notify(0,notificationBuilder.build())
}
}