【问题标题】:How to set ttl (time to live) while sending FCM notifications to WEB users?如何在向 WEB 用户发送 FCM 通知时设置 ttl(生存时间)?
【发布时间】:2019-03-05 05:40:36
【问题描述】:

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

【问题讨论】:

  • 您最终找到解决方案了吗?

标签: java firebase firebase-cloud-messaging


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    • 2017-05-22
    • 2016-10-08
    相关资源
    最近更新 更多