Trying to get OneSignal Player ID from GoNative

I’m using GoNative and I’ve got push notifications working. The last step I need to do is somehow store the Player ID (an ID OneSignal stores to associate a specific device with a specific person) that GoNative kicks out and associate it with the currently logged in issue.

I’ve tried everything I can think of in their documentation under Method #1 - Access the data directly via javascript
https://gonative.io/docs#registration-service

Such as using Javascript Toolbox plugin to run this Javascript and then send it to a Javascript-to-Bubble element:

function gonative_onesignal_info(info) {
console.log(info);
bubble_fn_1(info);
}

But it never puts out any info or is undefined. I’m VERY inexperienced with Javascript, based on those instructions, how would you get this data from GoNative and get it into Bubble?

If I need to elaborate any further please ask, I’m terrible at this and have been pulling out my hair all day trying solutions. Thanks.

P.S. I think this person was trying to accomplish the same thing but a different way: GoNative & OneSignal - How to link to a specific Bubble User
But what he is describing is way over my head, I don’t know how to do anything he described before he reached his problem lol

2 Likes

Hi Josh

Did you solve this? - I’ve been going nuts over the same thing

Ade

1 Like

@adeomomo Yes I did!

So in the footer on every page I have a Javascript to Bubble element (in my case the bubble_fn_suffix is player_id).

Then also in the footer I have a plain HTML element with this code inside of it:

<script type="text/javascript">
function gonative_onesignal_info(info) {
    bubble_fn_player_id(info.oneSignalUserId);
    console.log(info.oneSignalUserId);
}
</script>

The console.log line is optional, I just used it for debugging.

Finally, I have a workflow that takes the value of the Javascript to Bubble element and saves it to the current user in the database.

1 Like

Hi! May I ask for more specifics for what you did? I can’t seem to get mine to work through copying and pasting your method.

@michaelchang516 This is all I’ve done: https://imgur.com/a/2K2qo

That’s got a picture of my JavascripttoBubble element, my HTML element, and the workflow. That’s all I did on the Bubble end.

Don’t forget to turn on push notifications in your GoNative settings. These are what my settings look like: https://i.imgur.com/n0w57lb.png - Make sure Method #1 - Full Javascript is checked, and make sure to put in your OneSignal ID.

1 Like

Hi Josh4 ! Please I have the same problem ! I don’t know how to get Onesignal UserID with GoNative App. I tried the first method but it never puts out any info or is undefined. Please ! I need help !

So you’re usnig a JavascripttoBubble element? (It is not in Bubble by default, it comes from a plugin)

No ! What is JavascripttoBubble element ? I don’t know much about Javascript and I have newly registered here. :disappointed_relieved::disappointed_relieved::disappointed_relieved:

So follow my instructions in this post above: Trying to get OneSignal Player ID from GoNative

When I refer to Javascript to Bubble, that is an invisible element that you place in your page that comes from this plugin which you will need to install: https://bubble.io/plugin/toolbox-1488796042609x768734193128308700

Just install that plugin and follow my instructions in that post and it should work.

And to be clear, this is specifically if you are using Bubble in a GoNative wrapper (https://gonative.io/) that already has push notifications enabled and linked to a OneSignal account (who provides the push notifications). What I am describing is how to store the OneSignal unique ID and associate it with a single account so you can send a push notification to a particular user. If this isn’t exactly what your setup is, this post has no application for you.

1 Like

Thanks Josh. Is this solution still working out for you? Also, what pricing/package would you suggest for a first time potential buyer of GoNative? Thanks!

It’s still working out so far! We bought the single license + push notification package, I believe it came to around $800. Didn’t need any of the other add-ons or publishing services, I’m familiar with the app stores and how that works. There are definitely quirks and bugs to having a web app wrapper, but it beat just having a web app as our business really needed the push notifications to function properly.

Our use-case is basically a proof of concept app, and we’ll be transitioning to a native solution when we can afford to. So this setup is working for us but it just depends on what you are expecting from it.

Hello @josh4,

I have an exactly same configuration, and I cannot get the PlayerID … the Javascriptelementobubble do not get any data, this config works for IOS or Android?

is it still working for you ?

I am losing my hairs! :slight_smile:

I tried that as well, following step by step, but nothing, @josh, I noticed in your screenshot for gonative configuration

you have the premium one signal notification activated , but the OneSignal notification extension for IOS Disable ? is it on purpose ?

@loic.hennocq It is still working for me and I haven’t changed it all since I put it in.

The notification extension I just never enabled. It still isn’t enabled, I don’t know what difference it would make so I didn’t mess with it.

To be honest, I can’t remember specifically what I did to get it to stop being undefined. What are the results of the console.log for you?

If you share your app with me I would be willing to poke around to see if anything looks wrong.

Hello Josh,

Actually, I succeed to make it works as well following your recommendation, in my Gonative setup , the only difference with you, is I have all the Push notification activated.

I think the reason I failed too many time is because I forgot something:

Once the process is implemented, it seems you need to delete the app from your phone, and reinstall it, to have the notification “xxx want to sent you notification etc…” then when you click ok, the phone is registered as user (player ID) on the OneSignal website , then your code can retrieve the data.

On android there is no notification, but same logic

I guess that’s also the same logic with all the other method I tried.

Many thanks for this tuto and your help!

Has anyone been able to get this to work? I am currently testing this and it is getting the player_id into the javascript to bubble. Could anyone help me?

where do you put your Onesignal ID in?

stuck

Also bubble won’t let me finish the only when of the workflow part

Hey guys,
@josh4, Thanks for the tutorial - I appreciate it - it’s very helpful!

I’m wondering if you need to put the java element and html on every page - I noticed you placed it on the footer. One of my main pages doesn’t contain any footer.
Is there a reason you need to do this or can I strategically place it on one page i.e the login page or wherever?

Also, how exactly does this get triggered?

I also see you run the script every time your users ID doesn’t match up with the javascript value… can you make it so that it runs if java value is not empty And current users onesignal ID is empty? Or does the value change every so often?

Thanks for the help, any is appreciated!
Best,
Jason

Hi @josh4
just to make me clear, one question, so to solve this issue did you also use this plugin https://bubble.io/plugin/onesignal-push-notifications-1513549695528x981969459703709700 or just set up javascript only?

Sorry for the question because i didn’t have any knowledge about coding.

Thanks for any help