Once I saw this error, I googled enough and realized it was a manifest meta data problem, so I asked the question after fixing it and doing a lot of work.
ex) manifest default_notification_channel -> default_notification_channel_id
my log cat
2021-08-15 14:03:05.326 26315-27157/com.project W/FirebaseMessaging: Notification Channel requested (fcm_default_channel) has not been created by the app. Manifest configuration, or default, value will be used.
2021-08-15 14:03:05.327 26315-27157/com.project W/FirebaseMessaging: Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used.
my manifest
<service
android:name=".ui.fcm.MyFirebaseMessagingService"
android:stopWithTask="false"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>
and my fcm service class
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
Timber.d("Refreshed token: $token")
//TODO : Token save
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
Timber.d("MyFirebaseMessagingService onMessageReceived 성공!!!!")
if (remoteMessage.notification != null) {
Timber.d("MyFirebaseMessagingService noti.body = ${remoteMessage.notification?.body}")
sendNotification(remoteMessage)
}
if (remoteMessage.data.isEmpty()) {
return
}
super.onMessageReceived(remoteMessage)
}
private fun sendNotification(remoteMessage: RemoteMessage) {
val uniId: Int = (System.currentTimeMillis() / 7).toInt()
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent =
PendingIntent.getActivity(this, uniId, intent, PendingIntent.FLAG_ONE_SHOT)
val channelId = getString(R.string.default_notification_channel_id)
val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(remoteMessage.data["body"].toString())
.setContentText(remoteMessage.data["title"].toString())
.setAutoCancel(true)
.setSound(soundUri)
.setContentIntent(pendingIntent)
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel =
NotificationChannel(channelId, "Notice", NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
}
notificationManager.notify(uniId, notificationBuilder.build())
}
}
I'm asking this question because fcm doesn't work properly while I'm working on saving data to room. The push message is coming, but the data is not logged and I am not sure if the correct data is coming because such an error is coming out.
I haven't been able to solve this problem, can you help me yet?
