Same API on all Subdomains - Is it possible?

Hello my friends…

I want to ask if is possible to use the same account (API) on both of my Subdomains.
My Forums located on xiaomi-miui.gr/community and my wordpress page (news Page) located on news.xiaomi-miui.gr.

On wordpress I installed and enabled the pluging and all running just fine.
On my forums I installed the workerJS at xiaomi-miui.gr/community/ folder and declared the same API UID as on news.xiaomi-miui.gr.

Now the problem is that users had to accepted subscription on both domains, and receive double notifications.

Is it possible to use same API on Both domains (root domain and sub-domain) ?
Is it possible to have same cookie to avoid double notifications ?

All I want is to send notifications from my Wordpress Page (on new posts) on both domains without double them.

Thank in advance for your attention and sorry for my bad English .

We believe that you can the same code snippet on both sub-domains (our internal security verification is based on the top level domain, and not subdomain level - so as far was Webpushr is concerned, we allow you to use the same code snippet on multiple subdomains of the same parent site), and the browser will consider them to be “one” site for push notification purposes, only if the scope of the service worker is the same (root directory) on both subdomains. In your case, the scope is different for the two URLs and therefore, we think, the browser considers them as separate sites. We have frankly not tested this scenario and will lean on you to test it out and share your findings with the rest of the community. More info on service worker scope:

The scope of the service worker determines which files the service worker controls, in other words, from which path the service worker will intercept requests. The default scope is the location of the service worker file, and extends to all directories below. So if service-worker.js is located in the root directory, the service worker will control requests from all files at this domain. Source

1 Like

In my case the problem is that both URLs are different and used different installation aproach.
In case of news.xiaomi-miui.gr we use wordpress and installation done via Plugin.

In case of xiaomi-miui.gr/community we use Forums platform (Woltlab), and the setup done manually with same UID snipset code, but with different URL for webpushr-sw.js worker.

This setup as result asking double registration on news.xiaomi-miui.gr and xiaomi-miui.gr/community, and every time we publish a new article on wordpress, users receive double notifications (SPAM).

ΒΤW … On console I created to Sites : One for news.xiaomi-miui.gr and one for xiaomi-miui.gr (forums)
How is possible to delete xiaomi-miui.gr (forums) ?

Maybe if I delete this site the problem will be solved.

Thanks in advance for your attention

Dimitris

We are confused now. You have created two separate sites on Webpushr web console but you are only using ONE public key (inside our JS code snippet) for both sites? Is that right? if so, why do you think that deleting the second site (which is not getting used at all) will fix the issue?

1 Like

Don’t worry, we are both confused now. :rofl:

Correct !!!

I deleted the second site and declared on Forums (xiaomi-miui.gr/community header Code) the JS Code snipset of the news.xiaomo-miui.gr with some fixes as see below.

<!-- 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.src = "https://cdn.webpushr.com/app.min.js"; fjs.parentNode.appendChild(js);}(window,document, 'script', 'webpushr-jssdk-alternative')); webpushr('init','XXXXXXXXXXXXXXX code-here-removed for security reasons XXXXXXXXXXXXXXXX','https://news.xiaomi-miui.gr/webpushr-sw.js');</script> <!-- end webpushr tracking code -->

Still I have double registrations request and double notifications if visitors register on both URLs… :grinning:

Okay, thank you for the additional information.

Because of different URLs, two distinct/different subscription endpoints are getting generated because the browser considers them as two separate sites. I do not think you can change that based on your setup.

This means that you should register two separate sites in Webpushr web console so that users are attributed to the correct site by Webpushr. You should then use the appropriate public key for each site inside our JS code snippet or our WordPress Plugin. Otherwise, webpushr will be sending two duplicate push notifications to anyone subscribed on both sites/URLs because they are stored as two separate subscription endpoints.

In your specific setup at the moment, Webpushr platform is adding all subscription endpoints to one site (the one public key that you are using). Therefore, when you send a push notification, Webpushr sends to all endpoints associated with that one public key. Registering two separate sites in Webpushr Dashboard will solve the duplicate push issue.

Regarding the other requirements that you mentioned in your original post:

All I want is to send notifications from my Wordpress Page (on new posts) on both domains without double them.

It looks like this might not be possible.

1 Like

1st of all I am really amazed by your Super Fast and Awesome support !!!
If i can evaluate your support, I will Grand 10/10. :two_hearts:

2nd. I know that when i create separate 2nd Site then I will solve the problem of double notifications, but in this case I will loose registrations from the Second Site.

They will be registered to Receive Notifications of our news, but will be fake because if they not Register also on original news.xiaomi-miui.gr they will never receive Notifications from wordpress.

I know that I am asking too much, and Is my problem and not of your Service problem.

Your service until now run just Fine :+1:

Maybe on Welcome message I will inform them that in case they Receiving Double Notifications, to Un-Register the notifications from both URLs and keep just one.

Thanks Again

Yes, that is one possible solution. Not ideal but can work.

Thank you for the kind words and for using Webpushr.