<?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; |
This comment has been minimized.
This comment has been minimized.
Hello, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thank you :) |
This comment has been minimized.
This comment has been minimized.
thanx, bro, the code really helped!!! |
This comment has been minimized.
This comment has been minimized.
Thanks its working. :) |
This comment has been minimized.
This comment has been minimized.
Yeah ! Worked for me .... |
This comment has been minimized.
This comment has been minimized.
Does somebody have the android client for this code. I'm trying to figure out how to implement it but can't find anything useful. |
This comment has been minimized.
This comment has been minimized.
call via browser ? |
This comment has been minimized.
This comment has been minimized.
what is API_ACCESS_KEY and YOUR-API-ACCESS-KEY-GOES-HERE |
This comment has been minimized.
This comment has been minimized.
How to find API_ACCESS_KEY and THE_DEVICE_REGISTRATION_ID ? |
This comment has been minimized.
This comment has been minimized.
Hi Iam getting InvalidRegistration in results.. |
This comment has been minimized.
This comment has been minimized.
vinothc90 - Make sure you specify the reg id (the registration id you get back from google) as the id and the correct API key. I got the same error but it worked when I specified a reg id. |
This comment has been minimized.
This comment has been minimized.
Thanks ! |
This comment has been minimized.
This comment has been minimized.
Getiing error {"multicast_id":7717951616416938707,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]} |
This comment has been minimized.
This comment has been minimized.
So basically:
Is there something like this for iOS? |
This comment has been minimized.
This comment has been minimized.
Hi, I have used this code but i am getting error Unauthorized Error 401.Can you plz help me in this? I have search this error everyone providing different solutions not getting idea what to do. |
This comment has been minimized.
This comment has been minimized.
how can i get device registeration id |
This comment has been minimized.
This comment has been minimized.
Thanks :) How I can send notification to iOS ? |
This comment has been minimized.
This comment has been minimized.
Hi, Thanks ;) +10 |
This comment has been minimized.
This comment has been minimized.
Yes, but as a developer you must:
|
This comment has been minimized.
This comment has been minimized.
how should i send message to multiple devices |
This comment has been minimized.
This comment has been minimized.
Nice One :) I have one Question ? Can i send multiple Registration ids with single call $registrationIds = array( $_GET['id'] ); // $_GET['id'] pass multiple ids in array formate. like this : $registrationIds = array("id_1", "id_2", "id_3", "id_4"); |
This comment has been minimized.
This comment has been minimized.
great function, |
This comment has been minimized.
This comment has been minimized.
I am getting Unauthorized error ? Why, and which api key i have to use here Like android api key or server api key ? |
This comment has been minimized.
This comment has been minimized.
Getting This Error {"multicast_id":6564323768923178706,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} Please Help |
This comment has been minimized.
This comment has been minimized.
worked right out of the box. thanks a ton! |
This comment has been minimized.
This comment has been minimized.
Thanks so mutch bro |
This comment has been minimized.
This comment has been minimized.
Hi, How can I send a picture through push notification? |
This comment has been minimized.
This comment has been minimized.
Worked first time! thank you!!! |
This comment has been minimized.
This comment has been minimized.
Is there a example of sending a bigview? (wraptext) |
This comment has been minimized.
This comment has been minimized.
Hello... how can I send notification to iOS? |
This comment has been minimized.
This comment has been minimized.
Hi I have a demo app with text box with submit button. How to start from the beginning a a step by step. Could you help me out in this? |
This comment has been minimized.
This comment has been minimized.
@ lohiloki please read the artical the link I am Providing.I am sure it will help you to find your solution. |
This comment has been minimized.
This comment has been minimized.
Hello, Everything works perfectly for android ;) but when trying to send push to iOs it give me "InvalidRegistration" (after getting a valid id token) |
This comment has been minimized.
This comment has been minimized.
@thisdyingsoul for ios is a little different: <?php
// Provide the Host Information.
$tHost = 'gateway.sandbox.push.apple.com';
$tPort = 2195;
// Provide the Certificate and Key Data.
$tCert = 'dev.pem';
// Provide the Private Key Passphrase (alternatively you can keep this secrete
// and enter the key manually on the terminal -> remove relevant line from code).
// Replace XXXXX with your Passphrase
$tPassphrase = 'xxxxxx';
// Provide the Device Identifier (Ensure that the Identifier does not have spaces in it).
// Replace this token with the token of the iOS device that is to receive the notification.
$tToken = 'ada56107075e4d00f9da001b0ad71200cb953b99266e506884f6eab06f13f666';
// The message that is to appear on the dialog.
$empresa = "Petiskeira";
$tAlert = $empresa . ' tem um recado para você!';
// The Badge Number for the Application Icon (integer >=0).
$tBadge = 1;
// Audible Notification Option.
$tSound = 'default';
// The content that is returned by the LiveCode "pushNotificationReceived" message.
$tPayload = '{"endereco":"lauro oscar diefenthaeler","tel":"51 3561-8797","numero":"243","complemento":"0","id":"9","nome":"petiskeira","msg":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum."}';
// Create the message content that is to be sent to the device.
$tBody['aps'] = array (
'alert' => $tAlert,
'badge' => $tBadge,
'sound' => $tSound,
);
$tBody ['payload'] = $tPayload;
// Encode the body to JSON.
$tBody = json_encode ($tBody);
// Create the Socket Stream.
$tContext = stream_context_create ();
stream_context_set_option ($tContext, 'ssl', 'local_cert', $tCert);
// Remove this line if you would like to enter the Private Key Passphrase manually.
stream_context_set_option ($tContext, 'ssl', 'passphrase', $tPassphrase);
// Open the Connection to the APNS Server.
$tSocket = stream_socket_client ('ssl://'.$tHost.':'.$tPort, $error, $errstr, 30, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $tContext);
// Check if we were able to open a socket.
if (!$tSocket)
exit ("APNS Connection Failed: $error $errstr" . PHP_EOL);
// Build the Binary Notification.
$tMsg = chr (0) . chr (0) . chr (32) . pack ('H*', $tToken) . pack ('n', strlen ($tBody)) . $tBody;
// Send the Notification to the Server.
$tResult = fwrite ($tSocket, $tMsg, strlen ($tMsg));
if ($tResult){
echo 'Delivered Message to APNS' . PHP_EOL;
}else
echo 'Could not Deliver Message to APNS' . PHP_EOL;
// Close the Connection to the Server.
fclose ($tSocket);
?> |
This comment has been minimized.
This comment has been minimized.
Hi, It works but I have a little issue. The vibration/sound don't work.... And a question, can I use the light of the phone when I receive a notification? Thank's |
This comment has been minimized.
This comment has been minimized.
How do I call this script from Terminal? |
This comment has been minimized.
This comment has been minimized.
Thank you very much! It worked pretty well. |
This comment has been minimized.
This comment has been minimized.
My server responds: |
This comment has been minimized.
This comment has been minimized.
if the phone is silent configured. is the phone will ringing if the variable "sound" filled with '1' ? |
This comment has been minimized.
This comment has been minimized.
so sorry for my bad english |
This comment has been minimized.
This comment has been minimized.
how to find the registration Id? is it from android mobile phone? how to find? |
This comment has been minimized.
This comment has been minimized.
Wowowowo!!!!! Worked Nicely...I recommend everyone to use www file from Push plugin Example and This as a server side script. Get the crypto keys right, and you will rock |
This comment has been minimized.
This comment has been minimized.
Hi, Can anyone help me figure out where I am wrong? |
This comment has been minimized.
This comment has been minimized.
Thanks! Works like a charm! :D |
This comment has been minimized.
This comment has been minimized.
Hi, where find THE_DEVICE_REGISTRATION_ID? |
This comment has been minimized.
This comment has been minimized.
thanks a lot ... it worked for me .... but the messege what we encode on send notification.php file it does not appear over android notification messege .... what to do to show the messege we have encoded in pushnotification php file |
This comment has been minimized.
This comment has been minimized.
Thanks. |
This comment has been minimized.
This comment has been minimized.
Hi everyone |
This comment has been minimized.
This comment has been minimized.
Pls how can i redirect to a specific page on clicking the notification |
This comment has been minimized.
This comment has been minimized.
HI, I had used this script for android push notification, it was working fine but recently it stopped to work. it giving following error For android push notification:- "Curl failed: Failed to connect to android.googleapis.com port 443: Connection timed out." Can you please provide me a suitable solution regarding it. |
This comment has been minimized.
This comment has been minimized.
How to know Push Notification delivery status from parse server in Parse PHP? |
This comment has been minimized.
This comment has been minimized.
How to find THE_DEVICE_REGISTRATION_ID ? please, help me. |
This comment has been minimized.
This comment has been minimized.
Thank you , nice tutorial , i have one issue that getting only inline-notification i want outside status bar notification ,can you please help me out. |
This comment has been minimized.
This comment has been minimized.
I need to know whether we can you use posted code in our professional projects means would'nt it be a copyright issue, I'll be waiting for your kind response |
This comment has been minimized.
This comment has been minimized.
Thanks. It works perfectly. |
This comment has been minimized.
This comment has been minimized.
Hi everyone, Can anyone give an example for receive it in ionic? |
This comment has been minimized.
This comment has been minimized.
I'm in trouble he always returns "registration_ids" field is not a JSON array "someone has gone through it, you know tell me what I'm missing? |
This comment has been minimized.
This comment has been minimized.
Hi, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Kindly, check your API header and params against the one in GCM help doc. Also, verify the JSON here in http://jsonlint.com/ |
This comment has been minimized.
This comment has been minimized.
i have an doubt. in what format my app receives the message, weather in json or assoc array |
This comment has been minimized.
This comment has been minimized.
How the get the 'THE_DEVICE_REGISTRATION_ID'? Anyone who knows, please help. Thanks. |
This comment has been minimized.
This comment has been minimized.
@Zaeembinrehman look here: Here i have 3. |
This comment has been minimized.
This comment has been minimized.
Hello, My PUSH on android get overwritten when new push arrives. Is there any way i can show all pushes in list. What change I should do? |
This comment has been minimized.
This comment has been minimized.
Help... the following error is generated {"multicast_id":5549268725019984832,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]} |
This comment has been minimized.
This comment has been minimized.
Hi all, can any one help me to get rid of this? |
This comment has been minimized.
This comment has been minimized.
Thanks dude, it works prefectly :) |
This comment has been minimized.
This comment has been minimized.
You can use Push notification Service in now these days. it;s very common and save money to make an android App. Push notification Service providers provide you an dashboard for make a panel, to send notification on mobile directly. As I used www.pushalive.com for this service and easy to use. |
This comment has been minimized.
This comment has been minimized.
Hi, The script doesn't handle cannonical_ids. That is why some people are getting InvalidRegistration. Refer this link http://stackoverflow.com/questions/18200167/google-cloud-messaging-registration-id-expiration |
This comment has been minimized.
This comment has been minimized.
i can not able to fetch message in this script what should i do thanks in advance |
This comment has been minimized.
This comment has been minimized.
How can I set TTL value ? |
This comment has been minimized.
This comment has been minimized.
it returning unauthorized error 401 |
This comment has been minimized.
This comment has been minimized.
It's not working for FCM. |
This comment has been minimized.
This comment has been minimized.
what do you mean by "just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID"? |
This comment has been minimized.
This comment has been minimized.
@shubhkr "THE_DEVICE_REGISTRATION_ID" is your android device's token |
This comment has been minimized.
This comment has been minimized.
Hi everyone, If you want to use the script for Firebase Cloud Messaging (FCM), you can just try to change the POST URL: Take into account that you will have to migrate from GCM to FCM first. Further instructions about the migration can be found here: Firebase sample code for Android Client: |
This comment has been minimized.
This comment has been minimized.
Is there any easy way to get |
This comment has been minimized.
This comment has been minimized.
registration id is getting changed i guess each time i send a notification.. what to do? |
This comment has been minimized.
This comment has been minimized.
@shubhkr ,AFAIK ,Registration ID changes only when you uninstall your app( I am assuming, you are debugging your app in android studio and reinstalling it once in a while). If you don't explicitly uninstall the app, the ID won't change. |
This comment has been minimized.
This comment has been minimized.
GCM notification received but not displaying anything on my cellphone |
This comment has been minimized.
This comment has been minimized.
If you want to send push notifications using chrome then the registration id is the endpoint generated by the service worker(you need a service worker for your html frontend, you can use this tutorial https://goo.gl/YNrXjn Just do all the steps and hit next at the end of the page for the next lesson and you ll get there. |
This comment has been minimized.
This comment has been minimized.
Hey Hi!!, I have been using code for the past 2 months and it works.... all of the sudden , since this past saturday, it won't send the notification down to the app even though the status shows that it is successfully sent... the result echoed is as it seems that using the constant to insert the api key (define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' )) is not a good idea after all.. this was the problem why messages failed to reach the destination even though the results show success... I'm suggesting passing the api key as a normal variable from somewhere based on the project structure |
This comment has been minimized.
This comment has been minimized.
Well, to make this work with new firebase, refer this: |
This comment has been minimized.
This comment has been minimized.
@adhishlal does that work with iOS? If not is there an equivalent php script for Firebase that works with iOS, I can't seem to get it working with the iOS example from above. EDIT: got it working with the same function, ios requires the priority. |
This comment has been minimized.
This comment has been minimized.
I've spent a full day trying to make it works. It turns out at the end that my code is not a right way to show notification message. For those who cannot receive push notification message on client side although the message was successfully sent, make sure you code it properly. My case was due to not subscribe to topics to listen to (i.e. global), and no proper code to show notification (I didn't specify icon for notification in client side and it silently didn't show notification message to me at all). Check this example out https://github.com/googlesamples/google-services/tree/master/android/gcm. It also contains a java command line program to send out push notification in the similar way of the script above. Both works. All in all, I suggest to settle down with example in the link, make sure it works, then take the code and adapt to fit your case. Edit: added clarification on where to add code for icon notification, it's on android app side. |
This comment has been minimized.
This comment has been minimized.
I slightly modified above script too to reflect the doc as seen at https://developers.google.com/cloud-messaging/ (although FCM is newer, but google still support GCM for now). I changed
See my forked script at https://gist.github.com/haxpor/866efcbb155140f75dcec240a9714e2e Edit: added link to modified script, thanks to this script too. |
This comment has been minimized.
This comment has been minimized.
HI . i tried this code but this code is not working when we send message to multiple ids |
This comment has been minimized.
This comment has been minimized.
Thanks man.. its working :) |
This comment has been minimized.
This comment has been minimized.
Yes i got a nice output But why i am not receiving any notification yet? Can please anyone help me |
This comment has been minimized.
This comment has been minimized.
@haxpor can you please help me ? i didn't receiving notifications after getting this console output Here's the code of my send.php file from which am trying to send notification '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' => 'http://icons.iconarchive.com/icons/marcus-roberto/google-play/512/Google-plus-icon.png', 'smallIcon' => 'http://icons.iconarchive.com/icons/marcus-roberto/google-play/512/Google-plus-icon.png' ); $fields = array ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = array ( 'Authorization: key='.$api_key, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://gcm-http.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; ?>But am not receiving it although success json output |
This comment has been minimized.
This comment has been minimized.
@rohitcoder First of all try changing |
This comment has been minimized.
This comment has been minimized.
Thanks a Ton! Worked like a charm!! |
This comment has been minimized.
This comment has been minimized.
this code is runnable ... if any error occured that reason of device id or google api key... sorry for my bad english |
This comment has been minimized.
This comment has been minimized.
hi, {"server_response":[{"code":"firebase_true","message":"Notification sent successfully..."}]}{"multicast_id":6018791074250838508,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1471352487893305%c6f35c1ff9fd7ecd"}]} plz help |
This comment has been minimized.
This comment has been minimized.
I did a package for that, take a look:: |
This comment has been minimized.
This comment has been minimized.
How I can send other parameter in messages like sender_id, receiver_id etc.? |
This comment has been minimized.
This comment has been minimized.
If I am using PHP for my server and would like to send back data (eg. percentage) back to Android App, how should i do it? Can anyone help me? Thanks. |
This comment has been minimized.
This comment has been minimized.
how do i push gcm notification using PHP with a message and an image ?? please help.. |
This comment has been minimized.
This comment has been minimized.
Hi, this code is working fine for android app. What about Cross Platform app. If I am using PHP for my server and JavaScript for client and mysql for DB, which technique would be the best to get push notification? Please help. If the user is not actively using the app also, they doesn't require the app on a mobile device to be open in order for a message to be received. i.e. (This is like a smartphone to receive and display social media or text message alerts even when the device's screen is locked and the social media application that is pushing the notification is closed). One user should get a notification as soon as another user posts a comment using the app. I have searched some websites, they provide code only for app developed for Android, IOS, etc. but its not available for cross platform apps. Is this possible to implement in mobile app developed using Php, JS and mysql? Pls help me out with the code. Thanks in advance. I have tried the below code to get the notification count like Facebook and its working fine.
I want pop up (Push) like notifications even if the user is not using the app actively. |
This comment has been minimized.
This comment has been minimized.
what is the registration id, it is multiple or single and where i get registration id? |
This comment has been minimized.
This comment has been minimized.
thanks, it's work for me! |
This comment has been minimized.
This comment has been minimized.
Thanks alot.....it works |
This comment has been minimized.
This comment has been minimized.
Hi, A question: I tried it, but Service Worker show an notification with data undefined
Instead to get get data (mesage defined in php) after I launch this php script, Service Worker arrive in else case when fetch data... Can somebody help me to understand? Thank's |
This comment has been minimized.
This comment has been minimized.
How to open the app on a specific url after user pushed the notification? I'd appreciate any help. |
This comment has been minimized.
This comment has been minimized.
Best Simple Sample For Firebase Push Notification in below link : Tags : FCM - FIREBASE - firebase - base - fire - notification |
This comment has been minimized.
This comment has been minimized.
Hi, Is it possible to send multiple mobile numbers?.. I've tried but not able to find the solution. If so much appreciated for your help. Thanks!. |
This comment has been minimized.
This comment has been minimized.
muchas gracias! funciona de 10 |
This comment has been minimized.
This comment has been minimized.
Thank you, also I have to thank @haxpor to give the information to change `<?php // API access key from Google API's Console $headers = array $ch = curl_init(); 5 days trying to make a push from server side, with some headaches and frustration but now it finally works perfectly Sorry for my english. |
This comment has been minimized.
This comment has been minimized.
{"multicast_id":5352284567557772186,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]} error message to me Anybody can help me ? |
This comment has been minimized.
This comment has been minimized.
Thanks a million.. |
This comment has been minimized.
This comment has been minimized.
i am develpment ionic aplication for android, i have a problem with notifications, if i send menssage with token from console of firebase, the message is recibed in my app, also if use the this script , the menssage no recibed the response is {"multicast_id":9211726170113352103,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1485467751893255%e573a045f9fd7ecd"}]}" |
This comment has been minimized.
This comment has been minimized.
Unauthorized Error 401 , can someone please guide on this, please |
This comment has been minimized.
This comment has been minimized.
Hello, I have tried Your code, but the 'tickerText' and 'largeIcon' does not work. Best Greetings |
This comment has been minimized.
This comment has been minimized.
Does this (still) work? Or is it compatible with FCM? I tried it with a FCM test app but the moment it receives the broadcast, it crashes with:
|
This comment has been minimized.
This comment has been minimized.
@rohitcoder @junmper This worked for me. This makes it a Notification instead of a Data payload. Try the following link |
This comment has been minimized.
This comment has been minimized.
Thanks Bro |
This comment has been minimized.
This comment has been minimized.
I'm using the above php script for my fcm android push notifications. It seems to work however in the result I receive back "to\n".. whatever I echo in this script shows up in my phonegap-push-plugin error. Any reason why I get "to\n" back? |
This comment has been minimized.
This comment has been minimized.
For android do we have badge count? |
This comment has been minimized.
This comment has been minimized.
Can anyone send full code with explanation step by step how to send push notification in android? pls! Tons of thanks.. if get response ASP |
This comment has been minimized.
This comment has been minimized.
Using the above code, Can I send notification from browser ? |
This comment has been minimized.
This comment has been minimized.
Thanks.. |
This comment has been minimized.
This comment has been minimized.
Hi, I've tried this code and partially works, the notification arrieves empty, I have tried many data inputs and formats but haven'e get a positive result, can someone share a valid data payload so I can try? Json content I'm sending: {"to":"APA91basdfasdfasdfas", |
This comment has been minimized.
This comment has been minimized.
HI all...I used this GIST project/script to create a new GIST file and tutorial for both Android and iOS specifically for the FCM implementation: You can find it here: FCM Android/iOS Tutorial |
This comment has been minimized.
This comment has been minimized.
Thanks is work to me |
This comment has been minimized.
This comment has been minimized.
this code is not working for me...its return |
This comment has been minimized.
This comment has been minimized.
what is |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is my code:- 'Body Of Notification', 'title' => 'Title Of Notification', 'icon' => 'Default Icon', /*Default Icon*/ 'sound' => 'Default sound' /*Default sound*/ ); $fields = array ( 'to' => $registrationIds, 'notification' => $msg ); $headers = array ( 'Authorization: key=' .API_ACCESS_KEY, 'Content-Type: application/json' ); #Send Reponse To FireBase Server $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 Of FireBase Server echo $result; //$json_data = json_encode($result); //echo $json_data; ?> |
This comment has been minimized.
This comment has been minimized.
Unauthorized plz help |
This comment has been minimized.
This comment has been minimized.
{"multicast_id":5834261300676071883,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]} help ?????? |
This comment has been minimized.
This comment has been minimized.
Its working Thanks :) |
This comment has been minimized.
This comment has been minimized.
Thanks a lot dude |
This comment has been minimized.
This comment has been minimized.
Please check in the android studio log for Firebase Register Id Put that token in PHP |
This comment has been minimized.
This comment has been minimized.
Unauthorized |
This comment has been minimized.
This comment has been minimized.
@halatef @AstutTiwari have you found any solution ? , i am also getting same error/ |
This comment has been minimized.
This comment has been minimized.
I done this things successfully, in response i got {"multicast_id":9211726170113352103,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1485467751893255%e573a045f9fd7ecd"}]}" but still not getting notification on mobile phone>?
if their is problem in front end code then for the very first time from firebase notification need not to arrive ! where is the issue i didnt get it.. kindly help me to sort it out. Thanks in adv. |
This comment has been minimized.
This comment has been minimized.
Thanks, It's still working in 2018 :) |
This comment has been minimized.
This comment has been minimized.
Yea man works great in 2018 as well :P |
This comment has been minimized.
This comment has been minimized.
For those who have Just use key from Setting->Cloud messaging->Server key |
This comment has been minimized.
This comment has been minimized.
i can not receive notification when application is open when it is closed then only i receive notification can any one solve my error or what should i change in above code |
This comment has been minimized.
This comment has been minimized.
This worked well for me! https://github.com/adhishlal/Firebase-PHP/blob/master/sendnotification.php Thanks @adhishlal ! |
This comment has been minimized.
This comment has been minimized.
@sachin701 are you developing react-native app? |
This comment has been minimized.
This comment has been minimized.
@8ctopotamus Thank you. It works |
This comment has been minimized.
This comment has been minimized.
Hi @FernandoFactor! |
This comment has been minimized.
This comment has been minimized.
Hi all tech champ, |
This comment has been minimized.
This comment has been minimized.
Hi am a newbie, getting this error, any help appreciated Invalid (legacy) Server-key delivered or Sender is not authorized to perform request. |
This comment has been minimized.
This comment has been minimized.
Hi i'm new to fcm, and i had implemented this code using php codeigniter. im getting success message. but i'm not getting any notification in my mobile. i don't understand how to fix this. plz suggest me |
This comment has been minimized.
This comment has been minimized.
This is great for mobile notification. But you could also implement web push notification in PHP using any notification tool, like OneSignal. This will work both on all devices, whether it is mobile or desktop. Also, Firebase is a realtime database server, should it really be using for sending notification messages? |
This comment has been minimized.
This comment has been minimized.
I am facing an issues. When I send message from php I am getting the following response which seems okay. But my device not getting message. When I send message from firebase console it is sending and device receiving it successfully. Here is the response I am getting {"multicast_id":8066232449163018816,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1530197287203414%de3d6e02de3d6e02"}]} I saw many peoples face this problem. Can you please help me on that how to solve it or if any body knows how to fix this issue so device will get notification. Thanks in Advance and looking forward to hear back from you wonderful guy |
This comment has been minimized.
This comment has been minimized.
@rsp8055 how did you solve the issue... |
This comment has been minimized.
This comment has been minimized.
This coding working successfully |
This comment has been minimized.
This comment has been minimized.
im sorry but can you help me about reg id in react-native? |
This comment has been minimized.
This comment has been minimized.
In the array $msg change it 'message' to 'body' and in $fields change it 'data' to 'notification' |
This comment has been minimized.
This comment has been minimized.
I upgraded the app targetSDK to 26. I am not getting background notifications now. Does something in the payload have to change? cordova-support-google-services 1.3.1 "cordova-support-google-services"
|
This comment has been minimized.
This comment has been minimized.
@gustavomartins95 Where did you get this update? |
This comment has been minimized.
This comment has been minimized.
Invalid (legacy) Server-key delivered or Sender is not authorized to perform request. PLs Help ME Some error |
This comment has been minimized.
This comment has been minimized.
@DavidAlejandroM please share code for your index.html, do we need to activate/call any function? I keep getting "InvalidRegistrationID" |
This comment has been minimized.
This comment has been minimized.
you should use custom json(data) to send fcm |
This comment has been minimized.
This comment has been minimized.
Hello, The code was working very well, then from nowhere am receiving this error: "Error=DeprecatedEndpoint". And the notification is not being sent. Is there a fix for this? |
This comment has been minimized.
This comment has been minimized.
Same problem for me |
This comment has been minimized.
This comment has been minimized.
'https://android.googleapis.com/gcm/send' is outdated, use 'https://fcm.googleapis.com/fcm/send' instead. (worked for me this morning) Sample to check with new URL: Answer must be anything like this: |
This comment has been minimized.
This comment has been minimized.
Thank you @acaliebe!!! Its back on. |
This comment has been minimized.
This comment has been minimized.
Hello @acaliebe, |
This comment has been minimized.
This comment has been minimized.
U should use custom json (data) to send notification
…On Thu, 26 Sep 2019, 21:52 RuturajShweta, ***@***.***> wrote:
Hello, It works fine for me, It successfully gives a Success message but
actual notification is not getting. Dont know why this happened. Can you
please help me, I am eagerly waiting for your reply. Thanks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/5675017?email_source=notifications&email_token=AGAEPD7B34R6B6Q6QETJKCTQLTOT7A5CNFSM4HHJLYCKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFZOJY#gistcomment-3038364>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGAEPDZG44UI4LHKL466CNLQLTOT7ANCNFSM4HHJLYCA>
.
|
This comment has been minimized.
This comment has been minimized.
Thank you @acaliebe |
This comment has been minimized.
This comment has been minimized.
{"multicast_id":4314312645771955637,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} why no one is giving the solution of this error? when you are sharing your code you should make sure that it will execute successfully |
This comment has been minimized.
This comment has been minimized.
Please change end point
https://fcm.googleapis.com/fcm/send
…On Sun, 1 Dec 2019 at 2:11 PM, Swatantra Mukherjee ***@***.***> wrote:
Error=DeprecatedEndpoint
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/5675017?email_source=notifications&email_token=AGAEPDYCOWPP7HMUBIAMHDDQWN2DXA5CNFSM4HHJLYCKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF5BNK#gistcomment-3097301>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGAEPD7XGH45JAAVMFVR3JTQWN2DXANCNFSM4HHJLYCA>
.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
@wirakw it got from client(android) get regId(), just like generated string myabe like this : |
This comment has been minimized.
This comment has been minimized.
hi everybody, $msg = array $fields = array $headers = array all works fine, but no image is displayed on adroid |
This comment has been minimized.
This comment has been minimized.
Replace 'data' in line number 25 with 'notification' to get the notification messages displayed on the notification. |
This comment has been minimized.
This comment has been minimized.
Please how to get the registration ID ? |
This comment has been minimized.
This comment has been minimized.
Follow this video from FCM: |
This comment has been minimized.
This comment has been minimized.
Thanks!! it helped me alot!! |
This comment has been minimized.
This comment has been minimized.
You are welcome. |
This comment has been minimized.
This comment has been minimized.
Thank you man!!! It made worthy of my 2 days work. |
This comment has been minimized.
This comment has been minimized.
Thank You!! It really helped out.... |
This comment has been minimized.
Worked, thanks :)