[OneSignal Notification Plugin] How to send notification from server?

[OneSignal Notification Plugin] How to send notification from server?

  
Forge Component
(5)
Published on 2016-12-14 by Alexandre Costa
5 votes
Published on 2016-12-14 by Alexandre Costa

Hi,

To send notification from my app I should use PostNotification REST API Method? The documentations is here https://documentation.onesignal.com/reference

Asking just because on plugin demo this method is not used.


Thank you.

Hi yes, you need to use REST API, I will update OneSignal Api and OneSignal Demo tomorrow with some samples to help.

have you figured out how to send notifications at all? the only way I found was to copy the method from the OneSignalApi module and use it. Even then, I'm not even sure how I should use it, because of the input parameters

Hi Ricardo,

Yes coping the rest method is working fine. You can find information on one signal documentation:

https://documentation.onesignal.com/reference

for example request I use is:

{  "app_id": "xxxxxxxx",  "included_segments": [],  "include_player_ids": ["xxxxxxxxx"],  "url": "https://xxxxxx",  "data": {"parameter1": "value1", "parameter2" : "value2"},  "contents": {"en": "English message."},   "send_after":"2017-01-26T13:38:00"}

Mykola Tkachenko wrote:

Hi Ricardo,

Yes coping the rest method is working fine. You can find information on one signal documentation:

https://documentation.onesignal.com/reference

for example request I use is:

{  "app_id": "xxxxxxxx",  "included_segments": [],  "include_player_ids": ["xxxxxxxxx"],  "url": "https://xxxxxx",  "data": {"parameter1": "value1", "parameter2" : "value2"},  "contents": {"en": "English message."},   "send_after":"2017-01-26T13:38:00"}

ok, thank you. I also managed to make it work (:

I just found it weird you have to copy paste something, since usually you can just import everything you need from another module.

Ricardo Silva wrote:

Mykola Tkachenko wrote:

Hi Ricardo,

Yes coping the rest method is working fine. You can find information on one signal documentation:

https://documentation.onesignal.com/reference

for example request I use is:

{  "app_id": "xxxxxxxx",  "included_segments": [],  "include_player_ids": ["xxxxxxxxx"],  "url": "https://xxxxxx",  "data": {"parameter1": "value1", "parameter2" : "value2"},  "contents": {"en": "English message."},   "send_after":"2017-01-26T13:38:00"}

ok, thank you. I also managed to make it work (:

I just found it weird you have to copy paste something, since usually you can just import everything you need from another module.

The problem with the OneSignal API is the possibilities, there are many. I am putting together a more complete example with several of them, basic and some more complex, but they will always be suggestions that can be adapted.