Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Google Cloud Messaging (GCM) library

antongorodezkiy edited this page · 2 revisions
Clone this wiki locally

Codeigniter library for working with Google Cloud Messaging


Based on code of c2dm package, (c) 2011 & 2012

Simple example of usage:

// controller
public function send_gcm()
    // simple loading
    // 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
        $this->gcm->setMessage('Test message '.date('d.m.Y H:s:i'));

    // add recepient or few
        $this->gcm->addRecepient('New reg id');

    // set additional data
            'some_key' => 'some_val'

    // also you can add time to live
    // and unset in further

    // set group for messages if needed
    // or set to default

    // then send
        if ($this->gcm->send())
            echo 'Success for all messages';
            echo 'Some messages have errors';

    // and see responses for more info

    die(' Worked.');
Something went wrong with that request. Please try again.