问题
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).
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.
回答1:
There is currently no way to delete/remove a message from the server side/console. The message_id
is just an identifier that the message was sent successfully to the FCM server.
What is usually used for this scenario is the tag
parameter (see my answer here) where an existing notification with the same tag gets replaced with the newer one.
回答2:
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.
write this code on your 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
来源:https://stackoverflow.com/questions/48921958/can-you-expire-remove-a-message-remotely-on-fcm