如何通过FCM Admin SDK发送MessagingStyle样式通知?
问题与实现方案
当前实现方式
我目前通过向设备发送仅数据消息,然后在onBackgroundMessage回调中借助flutter_local_notifications插件,以MessagingStyle样式展示通知。
当前FCM请求JSON示例
{ "token": "token", "data": { "foo": "bar" }, "android": { "priority": "high" } }
Android端代码示例
MessagingStyleInformation messagingStyleInformation = MessagingStyleInformation( conversationTitle: name, Person(name: name), messages: messages); AndroidNotificationDetails notificationAndroidSpecifics = AndroidNotificationDetails(channelId, channelName, styleInformation: messagingStyleInformation, channelDescription: channelDescription, groupKey: groupKey, tag: id); NotificationDetails notificationDetails = NotificationDetails(android: notificationAndroidSpecifics); await flutterLocalNotificationsPlugin!.show( id, name, "last message", notificationDetails);
存在的问题
尽管目前还未出现限流情况,但仅数据消息优先级较低,存在被设备限流的风险,因此希望找到正确展示MessagingStyle通知的方法。
尝试的方案
我考虑直接通过FCM的通知配置指定样式,示例如下:
{ "token": "token", "android": { "notification": { "style": "MessagingStyle" } } }
内容的提问来源于stack exchange,提问作者flutroid
相关产品推荐
相关产品推荐

