web/lib/Zend/Mobile/Push/Message/Gcm.php
changeset 1230 68c69c656a2c
parent 808 6b6c2214f778
--- a/web/lib/Zend/Mobile/Push/Message/Gcm.php	Thu May 07 15:10:09 2015 +0200
+++ b/web/lib/Zend/Mobile/Push/Message/Gcm.php	Thu May 07 15:16:02 2015 +0200
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Mobile
  * @subpackage Zend_Mobile_Push
- * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
@@ -29,7 +29,7 @@
  * @category   Zend
  * @package    Zend_Mobile
  * @subpackage Zend_Mobile_Push
- * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  * @method     array getToken()
@@ -63,7 +63,7 @@
      * 
      * @var int
      */
-    protected $_ttl = 0;
+    protected $_ttl = 2419200;
 
     /**
      * Add a Token
@@ -199,11 +199,10 @@
     }
 
     /**
-     * Set time to live
-     * If $secs is set to 0 it will be handled as
-     * not being set.
+     * Set time to live.
      *
      * @param  int $secs
+     * @throws Zend_Mobile_Push_Message_Exception
      * @return Zend_Mobile_Push_Message_Gcm
      */
     public function setTtl($secs)
@@ -236,7 +235,7 @@
         if (!is_array($this->_token) || empty($this->_token)) {
             return false;
         }
-        if ($this->_ttl > 0 &&
+        if ($this->_ttl !== 2419200 &&
             (!is_scalar($this->_id) ||
             strlen($this->_id) === 0)) {
             return false;
@@ -266,9 +265,13 @@
         if ($this->_delay) {
             $json['delay_while_idle'] = $this->_delay;
         }
-        if ($this->_ttl) {
+        if ($this->_ttl !== 2419200) {
             $json['time_to_live'] = $this->_ttl;
         }
-        return json_encode($json);
+        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
+            return json_encode($json, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+        } else {
+            return json_encode($json);
+        }
     }
 }