Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229646

App is run forever

$
0
0

This is how i do it.

    $content = array(
                  "en" =>'notificationDescription'
                  );

    $fields = array(
      'app_id' => "YOUR OneSignal App ID",
      'include_player_ids' => array($device_token), // that id you are getting in alert with getIds function
      'data' => $notificationData, //if you want to send data ,payload
      'contents' => $content,
      'headings'=>array("en"=>'notificationTitle'),
      'android_sound'=>"notification"
    );

    $fields = json_encode($fields);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
                           'Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXX')); //you REST API Key from one signal
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    $response = curl_exec($ch);
    curl_close($ch);
    return $response;

Viewing all articles
Browse latest Browse all 229646

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>