Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to delete Push subscription from server

Just started playing with push notifications and I managed to handle all the subscription process and I'm saving endpoints and keys on my db. My questions is, what strategy should I follow, if any, to delete old subcription details from the database?. So, if someone allowed notifications and they revoke the permission how do I know who did it to remove the details from the database?. Because if the user unsubscribes I'll just get a null subscription from pushManager.

like image 609
Mario Lopez Avatar asked Oct 23 '25 13:10

Mario Lopez


1 Answers

For Pushpad we use these two strategies:

  • when a user revokes the permission the requests made using that endpoint will return 410 Gone and you should delete the endpoint
  • a developer can optionally trigger an unsubscribe with the Javascript SDK that will remove the endpoint from the server (this is useful for example to create a subscribe/unsubscribe button on the website)
like image 75
collimarco Avatar answered Oct 26 '25 09:10

collimarco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!