Forum Academy Marketplace Showcase Pricing Features

OneSignal Web Notifications API Connector

Hi,

I’m having trouble getting Web Push Notifications to work. My goal is to be able to do targeted web notifications to my users (as opposed to sending to entire segments).

There’s a OneSignal Plugin someone made, but I don’t believe it works for Web Notifications, and if it does, it doesn’t allow registering a device and therefore I cannot get the user’s Player Id, which is required to send a notification.

I’ve tried 2 things (written below) - both didn’t work. And I got instructions from OneSignal about using their SDK, but I’m not clear on how to install/initiate it (also written below).

It would be great if someone could provide some guidance. Perhaps @mebeingken @NigelG @mishav @romanmg ?

Thanks in advance!


Option 1 Attempted - Their “Typical Setup”:
On the “Configure Web Push” page (in OneSignal), I set the prompt as a button like this:

This path worked and created my device as a user.
PROBLEM: Since it’s not done via an API call, how do I get the Player Id of that person to be able to send him a targeted notification after?

Option 2 Attempted - Their API (which they recommend against using for this):
I tried the “Add a device” API call (which the documentation says not to do, but I can’t find another way to get the Player Id). This appears to work, but when created this way, the user gets set as “Not Subscribed” and therefore the Player Id that i get is considered invalid and it doesn’t send the notification to them when i try the API call to Create Notification


Instructions from someone at OneSignal - How do I do this in Bubble, since it seems to involve calling some OneSignal methods?

To get the OneSignal player ID on your site you use the getUserId method.

Most users wrap this with another method. For example, to get the player ID when a user subscribes, combine with the Subscription Change Event handler like so:

OneSignal.push(function() {  // Occurs when the user's subscription changes to a new value.  OneSignal.on('subscriptionChange', function (isSubscribed) {    console.log("The user's subscription state is now:", isSubscribed);    OneSignal.getUserId(function(userId) {      console.log("OneSignal User ID:", userId);      // (Output) OneSignal User ID: 270a35cd-4dda-4b3f-b04e-41d7463a2316         });  });});

Users only get a OneSignal playerID when they subscribe, so you can also use isPushNotificationsEnabled to wrap the getUserId method.

Bump!

There appear to be 4 plugins for one signal. Which is authoritative/best? How do we use it? I would really love to be able to send a notification to an individual user after they use our service and have moved to Google Maps, so we can get them back into the app to rate the experience. Possible?

Is an app pushed out with Deploy a mobile native app or a mobile web app? So confused!

Hi Ryan @ryan16

If you dig a little here, you can deploy your own notification system (free of charge) with Apple iOS and Android for your app. > Notification for native

For the web I suggest this free plugin OneSignal or
the paid plugin OneSignal $ by the same builder.

Thanks JohnMark but is an app pushed with deploy mobile native or mobile web?

1 Like

OneSignal has both. It gets complicated to have Apple, Android and browsers to handle the same thing.