So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By erdemontas
#69079 Hey guys,

I need to send push notification to a android device. Currently I'm doing this via pushetta like below;

Code: Select allvoid sendToPushetta(char channel[], String push) {
  WiFiClient client;
  client.stop();

  if (client.connect(serverName, 80))
  {
    client.print("POST /api/pushes/");
    client.print(channel);
    client.println("/ HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.print("Authorization: Token ");
    client.println(APIKEY);
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    client.println(push.length() + 46);
    client.println();
    client.print("{ \"body\" : \"");
    client.print(push);
    client.println("\", \"message_type\" : \"text/plain\" }");
    client.println();
  }
}


It works like charm but I need to do this via OneSignal. I had a look into onesignal documentation but I couldn't figure out how should I construct my Post to onesignal?
Onesignal documentation page is here : https://documentation.onesignal.com/reference
I think this is the part I should have a look at


Send to a specific segment - Create notification

curl --include \
--request POST \
--header "Content-Type: application/json; charset=utf-8" \
--header "Authorization: Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj" \
--data-binary "{\"app_id\": \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",
\"contents\": {\"en\": \"English Message\"},
\"included_segments\": [\"Active Users\"]}" \
https://onesignal.com/api/v1/notifications