OneSignal FREE plugin for FREE and UNLIMITED Push Notifications šŸ“±

Leaving it blank will load the html that is inside the www folder that comes with the wrapper.You can change that out to whatever you want but why would you leave it blank? That way you can never reference your Bubble app nor get the user to the app when they click a notification from their device.

Hey,

Sorry for the late reply. Happy Holidays past and future to all.
What exactly do you want to do?
I am really confused.

Has anyone figured out to load documents in the webview? I can click on a pdf for example and it opens it in the app, but there is no button to go back to the app so youā€™d have to close it and open the app again. I could swear I saw a ā€˜doneā€™ button once, but its definitely not there now.

Hi @mvandrei, thanks for the awesome plugin. I am however not having success with it. Iā€™ve configured it for my web app. Using WebApp YouTube instructions. But I every time I go to my website, I do not get a prompt.

I have a pro account so Iā€™m fully HTTPS. Are you aware of the plugin conflicting with other plugins?

I just canā€™t figure out why it wonā€™t work for me

1 Like

Thank you for this plugin @mvandrei! Itā€™s been very helpful and works great. The one issue that I run into is that it appears to send a ā€œ/nullā€ url field, even when you leave the url field blank. My bubble app serves as a back end for a native Android app (using Dropsource). When the url is forced, it attempts to automatically open the browser on the phone.

I agree with @stvnsnthn when he said the following:

OneSignal makes adding a LAUNCH URL optional like your plug-in does, but when it is left blank, it doesnā€™t attempt to open the browser when the notification is tapped on a mobile phone. Instead, tapping the notification opens into the native app when LAUNCH URL is left blank.

EDIT: SOLVED
So I went back and tried leaving a ā€œspaceā€ instead of a completely blank url field. Just literally hit the space bar one time in the url field and didnā€™t try to open a browser to a ā€œnullā€ url anymore.

2 Likes

@jamesonvparker @stvnsnthn
Okay, so if I got this right, youā€™re talking about the LAUNCH URL
Well, that is a feature that you can still use in superview.
You need to search and define the URL Scheme, change it from superview to WHATEVER.
Further more, you can set that each URL that contains your MAIN URL to be opened inside the wrapper so a URL like https://yourmainurl.bubbleapp.is/whateverpage will open your app upon tapping on the notification, on the whateverpage instead of index page.
And you can set that any other URL besides your main URL, to be opened in safari/pop-up.
To do so, you need to use the following scheme on onesignal at LAUNCH URL:
ā€œcustomurlscheme://ā€ + ā€œyour main URL without https or wwwā€ so in our example with:
whatever://yourmainurl.bubbleapp.is/whateverpage
this will make the app to open http://yourmainurl.bubbleapp.is/whateverpage instead of http://yourmainurl.bubbleapp.is/index

That is valid of iOS only.
For Android is a bit more complicated, OF COURSE. I will try to explain it tomorrow.

2 Likes

@mvandrei @vincent56
Jamesonā€™s discovery of tapping the spacebar in the URL field worked for me with the desired results.

I use ā€œpage is loadedā€ conditions and lots of conditional formatting to update what a user sees in the app/web when their data changes and forcing a page to reload whenever a push notification was received was causing unwanted delays. For example, visible counts on a userā€™s pending information would update prior to the user getting the notification that the info had been updated probably due to the bubble database being modified slightly faster than the API call to OneSignal to send the Push Notification.

I realize that I could probably send parameters in this URL to accomplish something similar, but that would require addressing a lot of other areas that I donā€™t really want to deal with right now.

Anyway, love the plugin, the OneSignal API is awesome and it appears that no changes are necessary to address my original concern.

1 Like

Hey @vincent56 thanks a lot for sharing what worked for you!

I wanted to clarify about the snippet that finally worked for you - the same snippet worked with both the iOS and Android SuperView wrappers?

Iā€™m using the snippet and the only thing I changed is the bubble_fn suffix, which is ā€œ1ā€ rather than ā€œ222ā€ in my app. (But like all the others Iā€™m still not getting any Player IDs in my database.)

Thanks a lot in advance for any help!

if it works for you, keep it :slight_smile:
But I doubt it, the iOS and Android snippets are different. I posted the ones that worked for me higher up the thread.

1 Like

It works! i did exactly what you did

2 Likes

Got them!

Here are the ones that worked for me finally:

iOS

 /* wk.bridge.min.js | v0.2 */
   (function(){if(window.isIOS){return}window.isIOS=function(){return navigator&&navigator.userAgent&&(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent))}}());
   (function(){if(window.bridge){return}window.bridge=function(){var callbacks=[],callbackID=0,registerHandlers=[];document.addEventListener("PacificDidReceiveNativeCallback",function(e){if(e.detail){var detail=e.detail;var id=isNaN(parseInt(detail.id))?-1:parseInt(detail.id);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=detail.name;if(name!==undefined&&registerHandlers[name]){var namedListeners=registerHandlers[name];if(namedListeners instanceof Array){var parameters=detail.parameters;namedListeners.forEach(function(handler){handler(parameters)})}}}},false);return{"post":function(action,parameters,callback,print){var id=callbackID++;callbacks[id]=callback;if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.pacific){window.webkit.messageHandlers.pacific.postMessage({"action":action,"parameters":parameters,"callback":id,"print":print||0})}},"on":function(name,callback){var namedListeners=registerHandlers[name];if(!namedListeners){registerHandlers[name]=namedListeners=[]}namedListeners.push(callback);return function(){namedListeners[indexOf(namedListeners,callback)]=null}},"off":function(name){delete registerHandlers[name]}}}()}());

 
console.log('window loaded');
var id;
function getOneSignalToken() {
          window.bridge.post('onesignaltoken', {}, (results, error) => {
               id = results.token;
           })
       }
getOneSignalToken();
setTimeout(function codeAddress() {

bubble_fn_1(id);


        },1000);

Android:

function getOneSignalToken() {
     alert("RegisterId:" + android.getOneSignalRegisteredId() );
}

var token; token = android.getOneSignalRegisteredId();
bubble_fn_2(token)

They were copied from various places from this post, which Iā€™ve now lost track of :joy:

Thank you again to everybody for your help!

5 Likes

Hi @mvandrei

I tried your plugin and after trying everything on this page , Iā€™M unable to have any notifications on web or mobileā€¦ :sob:
In fact I never have the prompt of notification or anythingā€¦
Do the bridge JavaScript change anyhow ?

2 Likes

Troubleshooting starts with checking your devices are actually assigned a playerid in onesignal. Is this the case?

Hi Vincent! No, the javascript returns nothing, and on my OneSignal panel, no user has been addedā€¦

Does your app prompt to allow to send notifications? At that point (given that your onesignal and firebase settings are correct in your app (not the bubble app)) the device should get registered in onesignal.

is this iOS or Android?

No, It not even prompt me for notifications. However, here is the thing, Iā€™m trying to do it in the case of Progressive webapp (i.e. added to the home screen app), so itā€™s not wrapped into a webview.

Neverthelees, Iā€™m also trying to get web notification in Chrome desktop with no luck tooā€¦

Sounds like a problem with the browser notification setup within onesignal? I havenā€™t setup browser notifications yetā€¦ :frowning:

1 Like

Okā€¦to understand: have you set up notifications only for apps that you have published on stores through webview?

Yes. I have looked at browser notifications but I havenā€™t implemented this. But since the devices are not getting registered with onesignal I think the issue is with not having onesignal webpush setup correctly.

1 Like