Last active
February 26, 2018 18:19
-
-
Save laptrinhcomvn/d8e8e5ee396ff01dbc861646e9f4ada4 to your computer and use it in GitHub Desktop.
Revisions
-
laptrinhcomvn revised this gist
Feb 26, 2018 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,15 @@ 'vibrate' => 1, 'sound' => 1, ); // custom sound should be existing in res/raw/notification.mp3 $msg = array ( 'body' => $_GET['body'], 'title' => $_GET['title'], 'vibrate' => 1, 'sound' => 'notification', ); $fields = array ( 'registration_ids' => $registrationIds, -
laptrinhcomvn created this gist
Feb 26, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php // API access key from Google API's Console; change to cloud messaging tab to get the server token define( 'API_ACCESS_KEY', 'YOUR_FIREBASE_API_ACCESS_KEY' ); $registrationIds = array( $_GET['id'] ); // prep the bundle $msg = array ( 'body' => $_GET['body'], 'title' => $_GET['title'], 'vibrate' => 1, 'sound' => 1, ); $fields = array ( 'registration_ids' => $registrationIds, 'notification' => $msg ); $headers = array ( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result; ?>