I'm trying to develop a standalone Telegram client for WearOS. Android Version: 13.0 Android API: 33 Tdlib: 1.8.0 I'm using Firebase to receive notifications from Telegram (notifications about new message for example) and for send it to my client. Messages are not encrypted.
Notifications from Firebase arrive, but with empty data and notification fields. Can Telegram send empty notifications to firebase? information about RemoteMessage object
I want to receive notifications from firebase with payload (not empty data/notification field). Received notifications exactly with non-empty payload.
Part of AndroidManifest
<service
android:name="ru.saiushev.telegramwearclient.NotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
FirebaseMessagingService implementation
class NotificationService : FirebaseMessagingService() {
companion object {
private val CHANNEL_ID = "CHANNEL_ID" //initialize channel ID
private val CHANNEL_NAME = "CHANNEL_NAME" //initialize channel name
}
override fun onNewToken(token: String) {
super.onNewToken(token)
}
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
notification(message.notification?.body) // Create a notification on device
}
override fun onDeletedMessages() {
super.onDeletedMessages()
}
}
Init block in TelegramClient class to set options and register device
init {
client.send(TdApi.SetLogVerbosityLevel(1), this)
client.send(TdApi.GetAuthorizationState(), this)
client.send(TdApi.SetOption("notification_group_count_max", TdApi.OptionValueInteger(100)), this)
FirebaseMessaging.getInstance().token
.addOnCompleteListener {
val token: String = it.result
if (!token.isNullOrEmpty())
client.send(
TdApi.RegisterDevice(TdApi.DeviceTokenFirebaseCloudMessaging(token, false), null),
this
)
}
}
What could I have forgotten or done wrong?