Shine
Shine

Reputation: 309

I can not able to receive the push notification from server through GCM?

I am new to GCM Push notification. I can able to get the Registration ID. I have send that Registration ID and API key to the server. But From Server side if they send Push means I can't able to receive that. Can You please any one help?

Upvotes: 1

Views: 695

Answers (2)

Kaushal Patel
Kaushal Patel

Reputation: 338

Please check the server key in google console and your server side.

Or see the following link :

https://developers.google.com/cloud-messaging/android/start.

Make sure about the use of the key for sending GCM.

Upvotes: 3

Rahul_Pawar
Rahul_Pawar

Reputation: 592

Write GCM BroadCastReaceiver and GCM intent service in your APP ..

At server side use that stored GCM ids to send notification...

<?php

function sendNotifications($con,$message) {

    // Get list of ids to send to
    $gcmRegID = getRegistrationIDs($con, null, null, null,null, null);
    //Post message to GCM when submitted
    $pushStatus = "GCM Status Message will appear here";
        if (isset($gcmRegID)) {     
            $gcmRegIds = $gcmRegID;//this is registered GCM id 
            $message = array("sc_description" => $description); 
            $message['sc_title']=$title;
            $message['sc_type']=$type;
            $message['sc_id']=$message_id;
            $pushStatus = sendMessageThroughGCM($gcmRegIds, $message);
            return $pushStatus;
        }
    }
?>

Upvotes: 0

Related Questions