From 886a7998f29771aa83454d7ef3dfbb8b61d71563 Mon Sep 17 00:00:00 2001 From: Dolgov Date: Tue, 10 May 2016 10:16:41 +0300 Subject: [PATCH] Add canonical regisrtration Id field for GCM --- Gcm.php | 11 +++++++++-- README.md | 8 ++++---- composer.json | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Gcm.php b/Gcm.php index 419712b..8b7f20e 100644 --- a/Gcm.php +++ b/Gcm.php @@ -13,6 +13,12 @@ class Gcm extends AbstractApnsGcm { public $apiKey; + /** + * @var string Canonical registration ID. + * @link https://developers.google.com/cloud-messaging/registration#keeping-the-registration-state-in-sync + */ + public $canonicalId; + private $_client = null; public function init() @@ -75,6 +81,7 @@ public function send($token, $text, $payloadData = [], $args = []) try { // send a message $result = $this->getClient()->send($message, $token, $this->retryTimes); + $this->canonicalId = $result->getCanonicalRegistrationId(); $this->success = $result->getErrorCode() != null ? false : true; if (!$this->success) { $this->errors[] = $result->getErrorCode(); @@ -154,7 +161,7 @@ public function sendMulti($tokens, $text, $payloadData = [], $args = []) // send a message $result = $this->getClient()->sendMulti($message, $tokens, $this->retryTimes); - $this->success = $result->getSuccess();; + $this->success = $result->getSuccess(); } catch (\InvalidArgumentException $e) { $this->errors[] = $e->getMessage(); // $deviceRegistrationId was null @@ -182,4 +189,4 @@ public function __call($method, $params) return parent::__call($method, $params); } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 2e70a5c..9412a73 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ The preferred way to install this extension is through [composer](http://getcomp Either run ``` -php composer.phar require --prefer-dist bryglen/yii2-apns-gcm "1.0.3" +php composer.phar require --prefer-dist intersvyaz/yii2-apns-gcm "1.0.4" ``` or add ``` -"bryglen/yii2-apns-gcm": "1.0.3" +"intersvyaz/yii2-apns-gcm": "1.0.4" ``` to the require section of your `composer.json` file. @@ -46,7 +46,7 @@ in your main.php your configuration would look like this // custom name for the component, by default we will use 'gcm' and 'apns' //'gcm' => 'gcm', //'apns' => 'apns', - ], + ] ] ``` @@ -120,4 +120,4 @@ $apnsGcm->send(\bryglen\apnsgcm\ApnsGcm::TYPE_APNS, $push_tokens, $message, 'badge' => 1 ], ) -``` \ No newline at end of file +``` diff --git a/composer.json b/composer.json index b0baa9e..5412b48 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "bryglen/yii2-apns-gcm", + "name": "intersvyaz/yii2-apns-gcm", "description": "Yii 2 Apns and Gcm together", "type": "yii2-extension", - "version": "1.0.4", + "version": "1.0.4.1", "keywords": ["yii2"," extension"," apns"," gcm"], "license": "MIT", "authors": [