How can I send push notification from inside the app?

Hi everyone!

I’m working on app at the moment and I need to send push notifications to a certain user when the user pushes the button. For example, user browses items in the app and orders one. Then, I will pass this order to the shop owner’s phone as a notification (I will probably need a second app for that or a simple user id for the owner).

How can I achieve that? Can you direct me to a tutorial or an example of that kind? Do I need some backend work to do that?

Thank you

Google has a REST API for sending push notifications. Look in our SampleCode folder under Notifications. There should be a google sample that sends push notifications.  There was an old tutorial that may still be up that shows how to use a PHP server and some free code called EasyAPNS (Easy Apple Push Notification Service) to use a web script to send a message through Apple’s servers. It tracks the user’s device ID and it can let you send to a batch of people or single addresses. Since it’s a PHP script (probably with a MySQL database under it), you could make a variant that would work with network.request() to send pushes.

But why re-invent the wheel? Check out the OneSignal plugin.

Rob

Do you mean using OneSignal REST API? If so, can this (https://documentation.onesignal.com/v2.0/docs/notifications-create-notification) be what I’m looking for?

Serkan

I believe Rob is referring to the OneSignal plugin for Corona SDK, the documentation of which can be found here:

https://documentation.onesignal.com/docs/corona-sdk-overview

Oh, I missed the PostNotification function the first time, thank you for pointing that out @Alex. So, I guess that (https://documentation.onesignal.com/docs/corona-sdk-api#PostNotification) should do it, right?

I believe you are creating an e-commerce app. I would recommend that you have your own backend server to handle the send-notifications, so you have more flexibility. You will need the feature where you can send to only 1 receiver (not to all that have installed your app). I think it is called ‘segments’ in OneSignal.

I create my own PHP push-notification server a few years ago, and it was a long process…

Google has a REST API for sending push notifications. Look in our SampleCode folder under Notifications. There should be a google sample that sends push notifications.  There was an old tutorial that may still be up that shows how to use a PHP server and some free code called EasyAPNS (Easy Apple Push Notification Service) to use a web script to send a message through Apple’s servers. It tracks the user’s device ID and it can let you send to a batch of people or single addresses. Since it’s a PHP script (probably with a MySQL database under it), you could make a variant that would work with network.request() to send pushes.

But why re-invent the wheel? Check out the OneSignal plugin.

Rob

Do you mean using OneSignal REST API? If so, can this (https://documentation.onesignal.com/v2.0/docs/notifications-create-notification) be what I’m looking for?

Serkan

I believe Rob is referring to the OneSignal plugin for Corona SDK, the documentation of which can be found here:

https://documentation.onesignal.com/docs/corona-sdk-overview

Oh, I missed the PostNotification function the first time, thank you for pointing that out @Alex. So, I guess that (https://documentation.onesignal.com/docs/corona-sdk-api#PostNotification) should do it, right?

I believe you are creating an e-commerce app. I would recommend that you have your own backend server to handle the send-notifications, so you have more flexibility. You will need the feature where you can send to only 1 receiver (not to all that have installed your app). I think it is called ‘segments’ in OneSignal.

I create my own PHP push-notification server a few years ago, and it was a long process…