我正在尝试通过 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/