Advertisement
ferdhika31

Push Plugin Cordova

Nov 17th, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. //https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#sound
  2.  
  3. <?php
  4. // API access key from Google API's Console
  5. define( 'API_ACCESS_KEY', 'AIzaSyCxHHyoYFqE9dVajF3fBIIsCtZFFQR5fug' );
  6. $registrationIds = array( 'c3MgWiq4LP4:APA91bGzAdXQgJ5Dv96QqBLDx3gHy0H-W2hYokAzY2WefdTtYBWpKioZE65wqAKO77ddXFGAFwmHPvfiFtvrcsqGokNZy9oCAL_bIASNLrgNxta_dIuZCcaSsbvP8fq5bcp4RRje69Iy' );
  7. // prep the bundle
  8. $msg = array
  9. (
  10.     'message'   => $message,
  11.     'title'     => 'Application Slick',
  12.     'subtitle'  => 'Aplikasi Slick',
  13.     'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
  14.     'vibrate'   => 1,
  15.     // "sound"      => "beep", // custom sound .\platforms\android\res\raw
  16.     "sound"     => "default",
  17.     "badge"     => "1",
  18.     'largeIcon' => 'large_icon',
  19.     'smallIcon' => 'small_icon'
  20. );
  21. $fields = array
  22. (
  23.     'registration_ids'  => $registrationIds,
  24.     'data'          => $msg
  25. );
  26.  
  27. $headers = array
  28. (
  29.     'Authorization: key=' . API_ACCESS_KEY,
  30.     'Content-Type: application/json'
  31. );
  32.  
  33. $ch = curl_init();
  34. curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
  35. curl_setopt( $ch,CURLOPT_POST, true );
  36. curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
  37. curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
  38. curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
  39. curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
  40. $result = curl_exec($ch );
  41. curl_close( $ch );
  42. echo $result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement