PHP code example of oxenti / cake_gcm
1. Go to this page and download the library: Download oxenti/cake_gcm library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oxenti / cake_gcm example snippets
Plugin::load('CakeGcm', ['autoload' => true]);
Plugin::loadAll();
$this->loadComponent('CakeGcm.Gcm', [
'api' => [
'key' => '*****'
]
]);
if ($this->Gcm->send($ids, $data, $parameters)) {
// do some stuff
} else {
// do other stuff
}
$response = $this->Gcm->response();
$this->Gcm->send('1');
$this->Gcm->send('1', [
'notification' => [
'title' => 'Hello World',
'body' => 'My awesome Hellow World!'
]
]);
$this->Gcm->sendNotification('1', [
'title' => 'Hello World',
'body' => 'My awesome Hellow World!'
]);
$this->Gcm->send(
['1', '2', '3', '4'],
[
'notification' => [
'title' => 'Hello World',
'body' => 'My awesome Hellow World!'
]
]
);
$this->Gcm->sendNotification(
['1', '2', '3', '4'],
[
'title' => 'Hello World',
'body' => 'My awesome Hellow World!'
]
);
$this->Gcm->send(
['1', '2', '3', '4'],
[
'data-1' => 'Lorem ipsum',
'data-2' => 1234,
'data-3' => true
]
);
$this->Gcm->send(
['1', '2', '3', '4'],
[
'data' => [
'data-1' => 'Lorem ipsum',
'data-2' => '1234',
'data-3' => 'true'
]
]
);
$this->Gcm->sendData(
['1', '2', '3', '4'],
[
'data-1' => 'Lorem ipsum',
'data-2' => 1234,
'data-3' => true
]
);
$this->Gcm->send(
['1', '2', '3', '4'],
[
'notification' => [
'title' => 'Hello World',
'body' => 'My awesome Hellow World!'
],
'data' => [
'data-1' => 'Lorem ipsum',
'data-2' => 1234,
'data-3' => true
]
]
);
$this->Gcm->sendNotification(
['1', '2', '3', '4'],
[
'notification' => [
'title' => 'Hello World',
'body' => 'My awesome Hello World!'
]
],
[
'delay_while_idle' => true,
'dry_run' => false,
'time_to_live' => 86400,
'collapse_key' => 'Gcm',
'restricted_package_name' => 'my_awesome_package'
]
);
php
""oxenti/cake_gcm": "dev-cake3"
},