#anonim_cl80 just made a spark in our ecosystem with 2 #NFTs ⚡🔥 Small moves, big meaning — every piece collected keeps the fire alive. Thank you 🙏#NFTCommunity #nftcollector #NFT_Support #eCash $XEC #NFTCollection #nftsales #CryptoTrading pic.twitter.com/vJaAfqtGxR
— NFToa (@nftoa_) August 26, 2025
Hi guys, are there any of you who are playing around with Firebase Cloud Messaging (FCM)? If so, surely those of you who are not satisfied with the way to capture data will definitely look for the most revolutionary way.
Yup, for me it's not a problem if the data is only in the form of title and body, but what if you use the payload method from the data, where the data carried is also A LOT, it's not a hassle, it's just that this has the potential for typos, considering that the key must be typed as a hard string.
Oh yeah, coincidentally I'm developing an Android app, and the Firebase SDK provides a facility in the form of a callback. onMessageReceived()
Considering the output result in onMessageReceived the form of Map<String, String> a clue, our clue is how to cast Map data to Class data.
So we need to use map delegate, so that the results of modifying the Class data are more or less like this,
data class MyData(
var variable1: String? = null,
var variable2: String? = null,
var variable3: String? = null) {
companion object {
fun from(map: Map<String, String>) = object {
var variable1 by map
var variable2 by map
var variable3 by map
val data = MyData(variable1, variable2, variable3)
}.data
}The implementation method is as below,
override fun onMessageReceived(fcm: RemoteMessage) {
fcm.notification?.let {
Log.d("tes", "title: ${it.title} body: ${it.body}")
}
fcm.data.let {
val payload = MyData.from(it) //--> ini dia hasil implementasinya.. wow bukan..
Log.d("tes_fcm", "payload: $payload")
}
}Good luck!
