Push notifications when button click

Hi @brianl

I tried this


but it didn’t return anything!!

Then I tried another … then it shows this message

Notice that I put my one signal appID and key ID

Now … I’m just want to know what’s the wrong with this api calling?

Looks like you didn’t set up the auth correctly. If you check the API docs, it’ll say what you need for your header. In the picture example, the key will go in app variable API

Already i put the APP ID on app variable and the API KEY on another … it doesn’t work.

Also connected it to the blocks directly as text block … it also doesn’t work.

Here is the how i got the one signal app id and api key … isn’t it right??


Or i have to fill in this ?

I received an email from one signal that:


Then … i coded as it is shown below… typical for the email code “as i understood”

At the end … i didn’t get anything neither response nor error

Could anyone help??

I have used push notifications but have done this server side. I use Xano and store the OneSignal Player ID there, so when I want to send a push notification to a user, I upload a record to Xano and have sent Xano to automatically send a push notification to the OneSignal Player ID. Push Notification does rely on Firebase but I don’t use Firebase or storing data, but I am sure something similar would be possible.
It took me a couple of months to figure out that the OneSignal Player ID is automatically created when an app with Push Notifications enabled is installed on a device. This was not clear in the Thunkable documentation and even the Thunkable support desk appeared to be unaware of this at the time.
I hope this helps.

What I would recommend is to try the following:

Set a text input to the push notification user id. Test it on a device to get that devices push notification user id. You can now send targeted push notifications if you copy down that string.

Then use something like Postman to try to send a push notification. You would want to do it similar or exactly the same as you would have it on Thunkable and then see the results. If it doesn’t work, then it has something to do with the API. If it works on Postman, let me know and I can give it a try when I have some time.

Hello @brianl and thank you for your help.

I tested it with postman with a “segment” name … It succeed … But with the player id it faild althiugh i copied it from one signal subscribtions page.

I’m not sure where you are copying from exactly, but I would keep trying to figure it out with Postman and then translate the knowledge to Thunkable

hi @brianl

it’s finally passed postman test and delivered to the subscriber with the subscription id …

i followed postman instructions and corrected the code … that was as the below at the end:

curl --request POST
–url ‘https://api.onesignal.com/notifications?c=push
–header ‘Authorization: key …’
–header ‘accept: application/json’
–header ‘content-type: application/json’
–data ’
{
“app_id”: “…”,
“contents”: {
“en”: “Good Morning new member”
},
“include_subscription_ids”: [“…”]
}

but when tried to make this code with thunkable blocks it failed…
here is the thuncable full blocks i bullt

could you help me knowing the issue to fix it.

thanks

What is the value of the green error block?

Unfortunately… it’s nothing.

It didn’t do anything

That’s because you’re setting Label6 to so many different values without any wait blocks. Only the last value is going to appear.

Create a new label and set Label7’s (or whatever it’s called) Text to error.


I changed it but it still nothing

If you’re not getting an error, is it possible you’re getting a value in the response block? I haven’t used OneSignal so I’m not sure what the response is supposed to show but you should get something… a response, an error, a status…?

No … i didn’t get any

Are you sure the code is firing? You can add debugging statements. I use this method: Debugging in Thunkable X (Video)