How to fetch the SID on the Subscription allow event?

I want to trigger the fetching of SID whenever a subscriber opts-in.
How can I achieve this?

My end goal is to schedule notifications to them with a 24h delay since they subscribed.

Please use the following code, the SID hook triggers automatically when a user is subscribed

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

Please I’m so not proficient in js console.log().
I need to get sid into PHP variable.
Also where exactly should I place the above script?

Please advise.

Thanks

Larry

Hi there,

We unfortunately do not offer any custom integration support at this time. We’d love to but we are entirely focused on enhancing Webpushr platform. Perhaps you can work with a developer who can help you achieve your goal?

Hopefully someone on this forum will be able to chime in and help you out.

Thanks, I have resolved it.
For those of you battling here is the answer.

use the fetch api to send the id to your PHP file.

The fetch_id will then be accessible in your PHP via: $_POST["fetch_id"]

<!-- start webpushr tracking code --> 
<script>(function(w,d, s, id) {if(typeof(w.webpushr)!=='undefined') return;w.webpushr=w.webpushr||function(){(w.webpushr.q=w.webpushr.q||[]).push(arguments)};var js, fjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.async=1;js.src = "https://cdn.webpushr.com/app.min.js";
fjs.parentNode.appendChild(js);}(window,document, 'script', 'webpushr-jssdk'));
webpushr('setup',{'key':'" YOU KEY " ' });

  webpushr('fetch_id',function (sid) { 
     fetch("YOUR PHP FILE", {
        method: 'post',
        body: {"fetch_id" : sid},
      })
    });

</script>
<!-- end webpushr tracking code -->
1 Like

Thank you :pray: for your contribution @Larry_Hurwitz