Search code examples
pushpad

Clean Subscriptions best practice for Pushpad debug


I'm testing a Pushpad implementation on several devices, with more browsers on each. Resetting previous subscriptions produces big headache.

For a given pushpad project, what is the best practice for resetting subscriptions on all browsers, on every device I'm testing on?


Solution

  • You can remove subscriptions in multiple ways.

    The easiest way to reset a subscription completely is to remove the permission for the website from the browser settings. The steps are described in this blog post.

    After you have revoked the permission:

    • the old endpoint is no longer valid and will be removed automatically by Pushpad (as soon as you try to send a notification to it)
    • when you try to subscribe again from that browser, the user will see again the permission prompt and a new endpoint (and a new subscription on Pushpad) will be created

    An alternative is to remove subscriptions from the Pushpad dashboard, using the REST API or with the Javascript SDK. For example:

    pushpad('unsubscribe');
    

    Note that these methods (Pushpad dashboard, REST API, Javascript SDK) are different from resetting permission from the browser settings. The difference is that these methods only remove the subscription from Pushpad (but do not make it invalid). If you try to subscribe the user again, he won't see the permission prompt and the old endpoint (which is still valid) will be sent to Pushpad again.