【发布时间】:2017-10-24 12:27:58
【问题描述】:
我在 Android 应用中注册了通知渠道,关注 GoogleSamples https://github.com/googlesamples/android-NotificationChannels
但是如何从 RemoteMessage 获取通知通道 ID,以便将其设置为 NotificationBuilder。
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
//int id = remoteMessage.getNotificationChannel(); // -something like this I could not find
}
我在 RemoteMessage 对象中找到了这个值
value[3]="notification_channel_system",所以我可以使用键值 android_channel_id https://firebase.google.com/docs/cloud-messaging/http-server-ref 将值设置为 Firebase 推送通知,但是当设备接收到它时我无法获取它。
如何从 PushNotification 获取此 id 并将其设置为通知生成器?
【问题讨论】:
-
notification_channel_system是否在您的有效载荷中?还是您只是在 RemoteMessage 中调试并发现这些值? -
这是我的有效载荷,我在 firebase 通知控制台中插入文本字段“Android 通知通道”,所以我确信通道数据来自正确的位置
标签: android firebase firebase-cloud-messaging android-8.0-oreo