Introduction

Webpushr lets you fetch the unique Subscriber ID associated with any single push subscriber. You can fetch this ID by calling fetch_id method inside _webpushrScriptReady function. It is the same ID that you see in your Webpushr Dashboard for each subscriber.

<script>
     webpushr('fetch_id',function (sid) { 
            });
</script>

Sample Fetch ID Code

Call fetch_id method inside our main JavaScript snippet, as shown below:

<script>
   <!-- Our JS snippet goes here  -->
   webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
</script>

Alternatively, you can also add the following code anywhere on the page:

<script>
  function _webpushrScriptReady(){
    webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
}</script>

You can also call fetch_id method on a custom event such as a click of a button:

<script>
$(element).click(function(){
    webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
});
</script>

Why fetch Subsciber ID?

In order to send highly targeted website push notifications using our REST API

Webpushr API Playground

Try sending push to a specific sid using our API. Just fetch the sid using method described on this page or via Webpushr Dashboard and send a push.

Try now

Limitations

Since subscription endpoints change over time, so will Webpushr's subscription IDs. What this means is that the ID will change for the same unique person over time. Please plan to update this periodically in your application.