-
Star
(424)
You must be signed in to star a gist -
Fork
(225)
You must be signed in to fork a gist
-
-
Save prime31/5675017 to your computer and use it in GitHub Desktop.
<?php | |
// API access key from Google API's Console | |
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' ); | |
$registrationIds = array( $_GET['id'] ); | |
// prep the bundle | |
$msg = array | |
( | |
'message' => 'here is a message. message', | |
'title' => 'This is a title. title', | |
'subtitle' => 'This is a subtitle. subtitle', | |
'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', | |
'vibrate' => 1, | |
'sound' => 1, | |
'largeIcon' => 'large_icon', | |
'smallIcon' => 'small_icon' | |
); | |
$fields = array | |
( | |
'registration_ids' => $registrationIds, | |
'data' => $msg | |
); | |
$headers = array | |
( | |
'Authorization: key=' . API_ACCESS_KEY, | |
'Content-Type: application/json' | |
); | |
$ch = curl_init(); | |
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/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; |
Replace 'data' in line number 25 with 'notification' to get the notification messages displayed on the notification.
Replace 'data' in line number 25 with 'notification' to get the notification messages displayed on the notification.
Please how to get the registration ID ?
Replace 'data' in line number 25 with 'notification' to get the notification messages displayed on the notification.
Please how to get the registration ID ?
Follow this video from FCM:
https://youtu.be/BsCBCudx58g
Replace 'data' in line number 25 with 'notification' to get the notification messages displayed on the notification.
Please how to get the registration ID ?
Follow this video from FCM:
https://youtu.be/BsCBCudx58g
Thanks!! it helped me alot!!
Thanks!! it helped me alot!!
You are welcome.
notification
Thank you man!!! It made worthy of my 2 days work.
Thank You!! It really helped out....
Is it possible to add a sound with the notification?
how to send to multiple devices at once with their tokens
It is not working in 2022
Yes it is.
…
On Thu 17 Sep, 2020, 10:04 PM ImtiazXYZ, @.> wrote: @.* commented on this gist. ------------------------------ Is it possible to add a sound with the notification? — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://gist.github.com/5675017#gistcomment-3457708, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGAEPD757MJT7ZE52AADVA3SGI3CRANCNFSM4HHJLYCA .
yes, but HOWWWWWWWWW
hi everybody,
i was trying to insert a picture to the message, but failed in any way, here is my code:
$msg = array
(
'body' => "Wir wünschen all unseren Kunden, Freunden und Familien ein frohes Osterfest und freuen uns Euch bald wieder in einem unserer Studios begrüßen zu dürfen!",
'title' => "Nachricht aus dem MoveCenter",
'vibrate' => 1,
'sound' => 1,
'image' => 'https://www.fentler.com/move/app1170/imagesApp/osterhase.jpg',
);
$fields = array
(
'registration_ids' => $registrationIds,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . 'MY KEY HERE',
'Content-Type: application/json'
);
all works fine, but no image is displayed on adroid