Skip to content

Instantly share code, notes, and snippets.

@johuder33
Last active August 8, 2016 20:52
Show Gist options
  • Save johuder33/f19a2a910861f7687de5f216c01d8946 to your computer and use it in GitHub Desktop.
Save johuder33/f19a2a910861f7687de5f216c01d8946 to your computer and use it in GitHub Desktop.
Get Started for OneSignal to send Web Push Notifications

#How to create an app for sending web push notifications with OneSignal

###1 Create a gmail Account, if don't have, if not, just skip until step 2.

###2 You need to create an app with Google Developers.

you can follow this OneSignal`s tutorial to get started

###3 Once you have created you App, it's time to set up your OneSignal Config.

###4 Finally create your own account to sign in into OneSignal and start sending notifications everywhere.

##How to send notifications using OneSignal API

Send a POST request to : https://onesignal.com/api/v1/notifications

then you need to pass these params into your body request to send the notifications

here the params JSON :

{
  "app_id": "HERE GOES YOUR APP ID", //You App ID, you can find it here : https://documentation.onesignal.com/docs/frequently-asked-questions
  "included_segments": ["All"], // what group of users or segments you want to include in the notification
  "data": {"foo": "bar"}, // some data to be passed to the app in background.
  "contents": {"en": "English Message"} // your message to be shown in notification
}

for attributes into JSON that you don't know, you can check it out here

to get it right you must pass some attributes into headers, that attributes are listed as followed

Authorization: Basic HERE_GOES_YOUR_REST_API_KEY 
Content-Type: application/json

there are another attributes to be passed, but these are the main for be able to send notification.

if you are interested to get involved about the all docs, checkout : Docs web push notification

Nota: Remember, this info apply only for Web Push Notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment