how to send notification to android from php

Solutions on MaxInterview for how to send notification to android from php by the best coders in the world

showing results for - "how to send notification to android from php"
Braxton
28 Apr 2016
1<?php
2    // Replace with the real server API key from Google APIs
3    $apiKey = "your api key";
4
5    // Replace with the real client registration IDs
6    $registrationIDs = array( "reg id1","reg id2");
7
8    // Message to be sent
9    $message = "Your message e.g. the title of post";
10
11    // Set POST variables
12    $url = 'https://android.googleapis.com/gcm/send';
13
14    $fields = array(
15        'registration_ids' => $registrationIDs,
16        'data' => array( "message" => $message ),
17    );
18    $headers = array(
19        'Authorization: key=' . $apiKey,
20        'Content-Type: application/json'
21    );
22
23    // Open connection
24    $ch = curl_init();
25
26    // Set the URL, number of POST vars, POST data
27    curl_setopt( $ch, CURLOPT_URL, $url);
28    curl_setopt( $ch, CURLOPT_POST, true);
29    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
30    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
31    //curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields));
32
33    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
34    // curl_setopt($ch, CURLOPT_POST, true);
35    // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
36    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields));
37
38    // Execute post
39    $result = curl_exec($ch);
40
41    // Close connection
42    curl_close($ch);
43    // print the result if you really need to print else neglate thi
44    echo $result;
45    //print_r($result);
46    //var_dump($result);
47?>
queries leading to this page
php send notification to browserhow to check notification sent to android from phphow to get push notifications from server to android phppush notifications android individual phphow to implement push notification in android using phpphp send notification to my phone iosphp send notification to my phoneis it possible to send notifications on desktop phpphp send notification to android firebaseandroid php send push notification examplephp push notification androidphp send push notification to androidphp send notification to android appsend notification phphow to send notifications to user in phphow to display push notification sent to my device in phpsend android push notification from phpsend notification to phone using phpphp push notification to androidhow to send notification to android app from php serversend fcm notification from phppush notification in php androidandroid client push notification from php examplephp push notification android and iosandroid push notification with phppush notification in android app phpcomplete android notification with phpsend push notification from php to androidandroid push notification phpphp android push notificationhow to send notification in php websitehow to create notification in php and android studioandroid php push notificationsend notification from php to androidhow to make notification in phphow to create push notification like that of android using phphow to send notification from website php android app development that recieve notification from phphow to build notification in android with phppush notification android from phpphp send push notification adroidhow to send notification to android from phppush notification from php to androidandroid app push notification phpphp android send push notificationsfcm send push notification to android using php stepssend notification to android using phphow to send notification to android from php