我正在尝试通过Firebase Cloud Messaging将通知发送给多个用户(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);
答案 0 :(得分:0)
我能够通过添加以下几行来进行配置:-
Map<String, String> headers = new HashMap<>();
headers.put("TTL", "3600");
headers.put("Urgency", "high");
WebpushConfig webpushConfig = WebpushConfig.builder().putAllHeaders(headers).build();