2017 © Pedro Peláez
 

cakephp-plugin cake_gcm

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging. This project is a fork from ker0x's repo.

image

oxenti/cake_gcm

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging. This project is a fork from ker0x's repo.

  • Thursday, March 24, 2016
  • by oxenti
  • Repository
  • 3 Watchers
  • 0 Stars
  • 48 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

CakeGCM

CakeGCM is a plugin for CakePHP to send downstream message to an Android or iOS device through Google Cloud Messaging, (*1)

Scrutinizer Total Downloads License, (*2)

Requirements

  • CakePHP >= 2.4

Installation

Run : composer require ker0x/cake_gcm:dev-master Or add it in your composer.json: ``` php "require": { "ker0x/cake_gcm": "dev-master" },, (*3)


### Enable plugin In your `app/Config/bootstrap.php` file add : ```php CakePlugin::load('Gcm');

or uncomment :, (*4)

CakePlugin::loadAll();

Usage

In your app/Controller/AppController.php file add :, (*5)

public $components = array(
    'Gcm.Gcm' => array(
        'api' => array(
            'key' => '*****'
        )
    )
);

Replace ***** by your API Key., (*6)

To get an API key, follow the instructions in this link: http://developer.android.com/google/gcm/gs.html#access-key, (*7)

Then, in an action of your Controller, add the following code:, (*8)

if ($this->Gcm->send($ids, $payload, $parameters)) {
    // do some stuff
} else {
    // do other stuff
}

where:, (*9)

  • $ids is a string or an array of device ids. (required)
  • $payload is an array containing the notification and/or some datas that will be passed to a device. (optional)
  • $paramaters is an array of parameters for the notification. (optional)

You could have the response of the request by using the function response():, (*10)

$response = $this->Gcm->response();

Examples

Send an empty notification to a device:, (*11)

$this->Gcm->send('1');

Send a notification to a device:, (*12)

$this->Gcm->send('1', array(
    'notification' => array(
        'title' => 'Hello World', 
        'body' => 'My awesome Hellow World!'
    )
));

or, (*13)

$this->Gcm->sendNotification('1', array(
    'title' => 'Hello World', 
    'body' => 'My awesome Hellow World!'
));

Send a notification to multiple devices:, (*14)

$this->Gcm->send(
    array('1', '2', '3', '4'),
    array(
        'notification' => array(
            'title' => 'Hello World', 
            'body' => 'My awesome Hellow World!'
        )
    )
);

or, (*15)

$this->Gcm->sendNotification(
    array('1', '2', '3', '4'),
    array(
        'title' => 'Hello World', 
        'body' => 'My awesome Hellow World!'
    )
);

Send datas to a device:, (*16)

$this->Gcm->send(
    array('1', '2', '3', '4'),
    array(
        'data' => array(
            'data-1' => 'Lorem ipsum',
            'data-2' => '1234',
            'data-3' => 'true'
        )
    )
);

or, (*17)

$this->Gcm->sendData(
    array('1', '2', '3', '4'),
    array(
        'data-1' => 'Lorem ipsum',
        'data-2' => 1234,
        'data-3' => true
    )
);

Send a notification and some datas to a device at the same time:, (*18)

$this->Gcm->send(
    array('1', '2', '3', '4'),
    array(
        'notification' => array(
            'title' => 'Hello World', 
            'body' => 'My awesome Hellow World!'
        ),
        'data' => array(
            'data-1' => 'Lorem ipsum',
            'data-2' => 1234,
            'data-3' => true
        )
    )
);

Send a notification with extra parameters:, (*19)

$this->Gcm->sendNotification(
    array('1', '2', '3', '4'),
    array(
        'notification' => array(
            'title' => 'Hello World',
            'body' => 'My awesome Hello World!'
        )
    ),
    array(
        'delay_while_idle' => true,
        'dry_run' => false,
        'time_to_live' => 86400,
        'collapse_key' => 'Gcm',
        'restricted_package_name' => 'my_awesome_package'
    )
);

License

The MIT License (MIT), (*20)

Copyright (c) 2015 Romain Monteil, (*21)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*22)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*23)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*24)

The Versions

24/03 2016

dev-cake3

dev-cake3 https://github.com/adewaleandrade/CakeGCM

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging. This project is a fork from ker0x's repo.

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp cloud google messaging

18/03 2016

dev-master

9999999-dev

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging

  Sources   Download

MIT

The Requires

 

cakephp cloud google messaging

01/12 2015

dev-cake2

dev-cake2

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging

  Sources   Download

MIT

The Requires

 

cakephp cloud google messaging

01/12 2015

v1.0

1.0.0.0

CakeGCM is a plugin for CakePHP to send notification to an Android device through Google Cloud Messaging

  Sources   Download

MIT

The Requires

 

cakephp cloud google messaging