Forum Documentation Showcase Pricing Learn more

OneSignal FREE plugin for FREE and UNLIMITED Push Notifications 📱


Hi, everyone

Big thanks to @mvandrei for this initiative great contribution for everyone. I’m currently developing a web app only. I’ve done exactly what @mproto1 shown but still not working.

Here’s my set up.

The script will run only when PlayerID is empty

Then I do the trigger instantly



and put the script somewhere in the page

Anything wrong?



@all sorry for disappearing like this.
I know internet is all against TMI, so I will be as short as possible.
I had my dog ill, the doctors believed it was cancer, and…after 6 months IT’S NOT! Yesterday was the last day of treatment and she’s okay! (turned 6 years old on Christmas). She also had to have a kidney removed… and a few other ‘real life’ issues that I had to take care of.
So… in a nutshell this is why I was absent.
My bubble app is almost ready thanks to a wonderful, talented freelancer whom worked around the clock at it.
I’ve started all this as an alternative to bringing the bubble app to mobile as well. So I shared my success on that.
Then I needed push notifications so I did the same. I went ahead and build a plugin for myself since the one made by codurly didn’t work as intended (for me at least). It lacked exactly what I needed: mobile support. And since I did it for me I thought I could share it with you guys.
I didn’t realize that I need multiple devices under same account, and then a few other things along the way.
The plugin works, but I can’t say for sure why it doesn’t for everybody.
Those that have it working are not on the thread or didn’t came back to say it works (happens to us too, so no blame here).
Since my app is almost finished, I need to finish this too. So I will refresh it, make sure it works on ALL platforms, easy install (maybe some reusable elements where I can do that) and a simple and clean tutorial.
It will take … maybe 1 month to finish the app, so around this date will have the plugin refreshed with tutorial and everything.
A bit late to the party but: Happy Holidays and Happy New Year!


Thanks you for all this @mvandrei it’s been so helpful. I think I’ve found the issue with the PlayerID not being pulled into the DB when running on an Android device, and it’s line 84 which errors - if(device.ios())

That may explain why others can’t get it stored into their DB. I’ll have a go and rewriting some parts of it later, with your permission. It works fine with iOS.


Sure, go ahead.
The latest version of the plugin is detecting the os and platform automatically: ios/android, mobile/desktop etc.
So it will be even easier to set it up, the plugin will do all the work.


Hi @mvandrei

I’ve found that by changing the following line from:



if (window.isIOS()) {

Allows for the script to get the PlayerID (when running through Superview on Android) correctly. Previously, that was erroring for me, but now it works on both platforms. Not sure if that could be something to do with the device I was using or not but thought it was worth mentioning anyway.

Trying to see JavaScript errors when running through Superview I found was a little tricky so by adding this function into the script, will make any errors popup as an alert, which just makes debugging the script a little easier that’s all. It can be removed afterwards.

window.onerror = function(msg, url, linenumber) {
  alert('Error message: ' + msg + '\nURL: ' + url + '\nLine Number: ' + linenumber);
  return true;

The JS script which I’m currently using at the moment and works for me on both devices, currently looks like this…

(function() {

  if (window.isIOS) {
  window.isIOS = function() {
    return navigator && navigator.userAgent && (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent))

(function() {
  if (window.bridge) {
  window.bridge = function() {
    var callbacks = [],
      callbackID = 0,
      registerHandlers = [];
    document.addEventListener("PacificDidReceiveNativeCallback", function(e) {
      if (e.detail) {
        var detail = e.detail;
        var id = isNaN(parseInt( ? -1 : parseInt(;
        if (id != -1) {
          callbacks[id] && callbacks[id](detail.parameters, detail.error);
          delete callbacks[id]
    }, false);

    document.addEventListener("PacificDidReceiveNativeBroadcast", function(e) {
      if (e.detail) {
        var detail = e.detail;
        var name =;
        if (name !== undefined && registerHandlers[name]) {
          var namedListeners = registerHandlers[name];
          if (namedListeners instanceof Array) {
            var parameters = detail.parameters;
            namedListeners.forEach(function(handler) {
    }, false);

    return {
      "post": function(action, parameters, callback, print) {
        var id = callbackID++;
        callbacks[id] = callback;
        if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.pacific) {
            "action": action,
            "parameters": parameters,
            "callback": id,
            "print": print || 0
      "on": function(name, callback) {
        var namedListeners = registerHandlers[name];
        if (!namedListeners) {
          registerHandlers[name] = namedListeners = []
        return function() {
          namedListeners[indexOf(namedListeners, callback)] = null
      "off": function(name) {
        delete registerHandlers[name]

//shows any errors as an alert
window.onerror = function(msg, url, linenumber) {
  alert('Error message: ' + msg + '\nURL: ' + url + '\nLine Number: ' + linenumber);
  return true;

function getOneSignalToken() {'onesignaltoken', {}, (results, error) => {
    id = results.token;

if (window.isIOS()) {
  console.log("its ios");
} else {
  console.log("its not ios");
  id = android.getOneSignalRegisteredId();

setTimeout(function codeAddress() {
}, 1000);

I hope it helps somewhat.



Just to carry on sharing any info/problems I’ve had today, here’s something else which may help others.

Don’t get confused with what @mvandrei has put up previously though as his great solution has worked for most, this is just what I’ve found that worked/didn’t work for me and what I’ve done to make it work!

I found when the JS ran, my JavascripttoBubble value was being set correctly with the playerID but if I then tried to use that JavascripttoBubble’s value in any workflow’s after that JS, all that happened was a blank value was put into my player ID field for the current user in the DB. It was a bit strange because it clearly had a value, I could create a text element and give it a dynamic value of “JavascripttoBubble’s X value” and I could see it fine. I just couldn’t use it within the same workflow as it was blank all the time.
Made no sense to me.

So to get around this, I did the following:

Put a tick in the box which Triger’s an event:


Then replaced the Custom workflow with a “JavaScript To Bubble Event” and move the action which modifies the current user into it. That way, when the JS sets the value, the event gets triggered automatically and that worked for me.

I also simplified the JS workflow to this:

I only have the 2 now, one runs the JS when the Page is Loaded AND the Current User is Logged In.
The other gets Triggered when the JavascripttoBubble’s value is changed.
I removed the Pause and the Custom Event that was before.

Hope it helps someone!


I have the API key from the project inside of OneSignal but when i put it in to the ‘authorization’ section it still doesn’t work.

Where is it supposed to go?

Do i need all of the other settings too? If so, where do i find those?



id = android.getOneSignalRegisteredId();

this line of error as “android” unspecified


in the script put in what form?


Hi @justincrabbe

This is what I have in all those Plugin values…


Hi @contato

When is the error occurring? Does it occur as soon as you preview your page through a browser (all browsers?) (ie when it’s first loaded?) or on an Android device/iOS device only? or every time regardless of where it’s loaded from?


I’m probably missing some basic thing, but here’s the only workflow option I see in the OneSignal Web notifications plugin:

I’m trying to figure out how to send individual notifications to people - is anyone able to point me in the right direction? (I don’t see an option to set the playerId as a recipient there)

(I understand that a preliminary step to doing this would be registering the user as a player, but once that’s done, how do i sent individual notifications?)

Thanks in advance!


That looks like the “OneSignal - Web Notification” plugin, look for the “OneSignal - Push Notification” plugin.


Will those work on the web? Or only in iOS/Android apps?

(I’m trying to get a web-based solution going)


Ah ok, hadn’t realised that. So to get push notifications working with the Superview App for iOS/Android you’d need the OneSignal Push Notification plugin. For what you require, i.e. just the web based solution, web notifications then you’re right it’s the OneSignal - Web Notification plugin and for that one you don’t need any of the JS script stuff that’s mentioned in this rather long post. Actually I tried getting that working for myself too and I managed to get there but with some hassles.

My configuration I used looked like this:

There shouldn’t be much configuration apart from the above required, if you get all that right then as soon as you launch your site, you should get prompted with a browser message asking you want to accept notifications and then you can use the only action available to populate which is the one your image shows. I wanted to do the same thing though, push a web notification out to a specific player ID and I wasn’t able to because there was no player ID available to use in that action (like there is with @mvandrei plugin)

Instead I think it uses Segments instead, so when you look in your OneSignal account, you see something like this…

These are the 4 default segments which you can use. It’s great if you have 50 Active Users for example (in the Active Users segment) because you can use that one action to send a message to all of them but in my opinion I think the plugin could do with an additional option which would allow you to send not only to segments but to an individual player ID, I don’t think it will do that though.

Your only other option is use the Bubble API Connector and send one that way. It can be done, I got as far as what shows in the following screenshot but I can’t remember now if I ever got it to work, one day I’ll end up revisiting it!


You’ll need to also get the PlayerID into the Bubble database, this is how you do it…

Once you have the OneSignal - Web Notification plugin installed and configured, when you open your site it should prompt you with something like this (depending on how you have the notifications configured in your OneSignal settings.

If you’re not seeing that popup, then try closing the browser and re-opening (not just refreshing site) and check the configuration in the Settings area in your OneSignal account.

It will be in here, make sure you have it setup correctly, you have the Permission Prompt Setup completed and the Label is in your Plugin settings.


When the user clicks ALLOW and accepts any other prompts afterwards, that’s when the user gets registered in OneSignal and when that happens, the Player ID is stored in your browser which we can retrieve by running a small JS script. In order for this JS script to work, you’ll want to upload the 3 SDK files which can be found here: to the root of your site… @mvandrei maybe we can put these SDK files into your plugin?

Then you can run this is in the Console:

If you don’t’ have the SDK files uploaded correctly you’ll see this returned:


And if you do have them installed correctly, then you’ll get this:


Now set yourself up with a Run javaScript action with the JS in it, use the JavascripttoBubble event too and you should be able to get it into the Current User fields. If you’re not sure on how to that part let us know and I’ll go into more detail, running out of time right now.

We should be able to put all this into another plugin with the API call in there to make it easier for ourselves… OR if @mvandrei if you’re there, maybe we add it to your Plugin!!


thanks for the update @pork1977gm. I will bring something even cooler than what I’ve provided by now, in about 10 days. Then, I will update the plugin right after. We need to keep track of devices, and be sure we don’t re-register an PID over an existing one, so replacing the old one from another device, OR not register it if it’s already there (from another device) e.g.: phone, tablet and computer/laptop.


Yep, ok understood, all good!


is giving this message on the Android studio console
I’m trying to get the ID to send individual notification, I’m using OneSignal Push Notification and with SuperView


Awesome @pork1977gm, thanks.

@mvandrei, are you still planning on adding these options into a the plugin for OneSignal Web Notifications?

(meaning: should i wait a week for that and just use the plugin?)