首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用FCM Java API发送APNS mutable_content

使用FCM Java API发送APNS mutable_content
EN

Stack Overflow用户
提问于 2018-03-07 16:12:05
回答 1查看 1.8K关注 0票数 2

根据herehere,当使用FCM REST API时,FCM支持将mutable_content变量作为布尔值发送。但是我在Firebase Admin Java API中找不到一个等效的方法。

代码语言:javascript
复制
final ApsAlert alert = ApsAlert.builder()
       .setTitle("Test notification")
       .setBody("Hello World")
       .build();

final Aps aps = Aps.builder()
       .setAlert(alert)
       .setBadge(messageCount)
       .setContentAvailable(messageCount > 10000)
       .setCategory("tesy")
       .build();

final ApnsConfig config = ApnsConfig.builder()
       .putHeader("apns-id", getMessageId())
       .setAps(aps)
       .putCustomData("type", "test")
       .putCustomData("mutable_content", true)
       .build();

remoteMessage.setApnsConfig(config);

已尝试将其设置为ApnsConfig中的自定义数据值,但是不起作用。

PS:这个方法在Spring boot服务器上运行,将通知发送给用户。

EN

回答 1

Stack Overflow用户

发布于 2020-04-06 12:25:13

我也在搜索不同的网站,最后,我得到了适当的输出(IOS)

代码语言:javascript
复制
 final ApsAlert alert =
                    ApsAlert.builder()
                        .setTitle(notification.getEventType())
                        .setBody(notification.getEventDescription())
                        .build();
                final Aps aps =
                    Aps.builder()
                        .setAlert(alert)
                        .setContentAvailable(true)
                        .setMutableContent(false)
                        .build();
                final ApnsConfig apnsConfig =
                    ApnsConfig.builder()
                        .setAps(aps)
                        .putCustomData("eventId", notification.getEventNumber())
                        .putCustomData("category", notification.getCategory())
                        .putCustomData("priority", notification.getEventPriority())
                        .build();
                message =
                    Message.builder()
                        .setToken(notificationRequestDto.getTo())
                        .setApnsConfig(apnsConfig)
                        .build();

在这段代码中,我们还传递了自定义数据。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49147002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档