How to set ttl (time to live) while sending FCM notifications to WEB users?

acsh :

I am trying to send notifications to multiple users (WEB, WAP) through Firebase Cloud Messaging. But I am not able to set the time to live for notifications.

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);
acsh :

I was able to configure the same by adding following lines:-

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105559&siteId=1