您可以在FCM上远程过期/删除消息吗? [英] Can you expire / remove a message remotely on FCM?

查看:96
本文介绍了您可以在FCM上远程过期/删除消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将FCM用于推送消息.很好,但是我有一个客户端,它需要能够在发送推送消息后将其删除-(以防出现错误/错别字等).

I'm using FCM for my push messages. Its great, however I've a client that needs to be able to remove a push message once its sent - (in case of mistakes / typos etc).

我知道您可以从主题排队发送消息时获得消息ID,只是想知道是否有一种方法可以使用该ID来使这些消息远程过期.即删除邮件.

I know you can get the message id from when the Topic is queued to send messages, just wondering if there is a way to then use that ID to expire those messages remotely. i.e. to delete the message.

推荐答案

在某些情况下,您可能希望替换通知来通知用户而不是静默更新.聊天应用程序就是一个很好的例子.在这种情况下,您应该将 tag renotify 设置为true.

There are scenarios where you might want a replacing notification to notify the user rather than silently update. Chat applications are a good example. In this case you should set tag and renotify to true.

在您的 sw.js

    const title = 'Notification 2 of 2';
    const options = {
      tag: 'renotify',
      renotify: true
    };
    registration.showNotification(title, options);

您可以在此处上进行测试,方法是单击重新通知按钮

You can test demo on here by clicking in renotify button

这篇关于您可以在FCM上远程过期/删除消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆