Send Mass Push Notifications By Platform - Java

Source Code Option 1: OkHttpClient

  

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "api_key=YOUR-API-KEY&msg_title=YOUR-MESSAGE&destination_url=YOUR-URL&platform=Android-iOS-Windows");
Request request = new Request.Builder()
  .url("https://send.pushnotificationapi.com/v1/push/send_by_platform")
  .post(body)
  .addHeader("content-type", "application/x-www-form-urlencoded")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

 

Source Code Option 2: Unirest

  

HttpResponse<String> response = Unirest.post("https://send.pushnotificationapi.com/v1/push/send_by_platform")
  .header("content-type", "application/x-www-form-urlencoded")
  .header("cache-control", "no-cache")
  .body("api_key=YOUR-API-KEY&msg_title=YOUR-MESSAGE&destination_url=YOUR-URL&platform=Android-iOS-Windows")
  .asString();