w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Android phonegap send push notification using Google Cloud Messaging using php

Here is the GCM code and its working properly with my device though its in CI framework but hope you can use it. It is compulsory to add device_id for the push and also the passphrase you'll get for the site. just try it.

function sendNotification($device_id,$message) {
        /*echo $device_id;
        echo "<br>";
        echo $message;*/

        // note: you have to specify API key in config before
        // simple adding message. You can also add message in the data,
        // but if you specified it with setMesage() already
        // then setMessage's messages will have bigger priority
        $msg = $this->gcm->setMessage($message);

        // add recepient or few
        // set additional data
        // also you can add time to live
        // and unset in further

        // set group for messages if needed
        // or set to default
        // send
        return $this->gcm->send();

Hope it'll solve your problem.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.