gpt4 book ai didi

java - 给WEB用户发送FCM通知时如何设置ttl(time to live)?

转载 作者:行者123 更新时间:2023-11-30 12:07:24 25 4
gpt4 key购买 nike

我正在尝试通过 Firebase 云消息传递向多个用户(WEB、WAP)发送通知。但是我无法设置通知的生存时间。

Map<String, String> map = new HashMap<>();
map.put("status", article.getStatus());
map.put("headLine", article.getHeadLine());
map.put("caption", article.getCaption());
map.put("thumb", article.getThumb());
map.put("tag", article.getTag());
map.put("webUrl", article.getWebUrl());
map.put("category", article.getCategory());

WebpushConfig webpushConfig = WebpushConfig.builder().putAllData(map).putHeader("TTL", ttl + "").build();
Message message = Message.builder()
.setWebpushConfig(webpushConfig)
.putAllData(map)
.setTopic(id)
.build();
String response = FirebaseMessaging.getInstance().send(message);

最佳答案

我可以通过添加以下行来配置相同的内容:-

Map<String, String> headers = new HashMap<>();
headers.put("TTL", "3600");
headers.put("Urgency", "high");
WebpushConfig webpushConfig = WebpushConfig.builder().putAllHeaders(headers).build();

关于java - 给WEB用户发送FCM通知时如何设置ttl(time to live)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54996103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com