How to send pushnotification to andoroid using php

Hi Friends,


Today I am discussing about push notification on android device through PHP. To know more about push notification you can visit . Now I am going to tell you how to send push notification to android using PHP. I have created a function that you can use for push notification for android.

function sendPushNotification($apiKey,$registrationIDs,$message)

$url = ‘’;

$fields = array(
                ‘registration_ids’  => $registrationIDs,
                ‘data’              => array( “message” => $message ),

$headers = array(
                    ‘Authorization: key=’ . $apiKey,
                    ‘Content-Type: application/json’

// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
// Execute post
$result = curl_exec($ch);
// Close connection
return $result;


In this function you will need to send 3 parameters

1) Api Kye:- API key (provide by googe)

2) Registration ID:- An array that contain the list of device token on which you have to sent the notification.

3) Message:- Message that you want to sent in push notification.

Use this function keep smiling. 🙂




Share This Post

Recent Articles

Leave a Reply


© 2019 Networkocean. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie