Wang Chen 4 vuotta sitten
vanhempi
commit
6a6763181b
2 muutettua tiedostoa jossa 10 lisäystä ja 49 poistoa
  1. 9 46
      app/Libs/Push/VPush/VPush.php
  2. 1 3
      app/Modules/Push/Services/PushService.php

+ 9 - 46
app/Libs/Push/VPush/VPush.php

@@ -50,12 +50,12 @@ class VPush
 
     /**
      * 设置推送消息
-     * @param $title
-     * @param $content
-     * @param $url
-     * @param $regId
+     * @param       $title
+     * @param       $content
+     * @param       $url
+     * @param array $regId
      */
-    public function setPushData($title, $content, $url, $regId)
+    public function setPushData($title, $content, $url, $regId = [])
     {
         // 赋值
         $this->_title       = $title;
@@ -104,6 +104,9 @@ class VPush
         if (!$this->_taskId) {
             throw new InvalidArgumentException('VIVO推送必须要设置taskId');
         }
+        if (!$this->_regId) {
+            throw new InvalidArgumentException('VIVO推送必须要设置regId');
+        }
 
         $data = [
             'regIds'    => $this->_regId,
@@ -122,7 +125,7 @@ class VPush
     public function sendAll()
     {
         // 校验参数
-        $this->checkSendAllParam();
+        $this->checkParam();
         $data = [
             'requestId'       => Utils::randCode(),
             'title'           => $this->_title,
@@ -203,46 +206,6 @@ class VPush
         if (!$this->_timeToLive) {
             throw new InvalidArgumentException('VIVO推送必须要设置timeToLive');
         }
-        if (!$this->_regId) {
-            throw new InvalidArgumentException('VIVO推送必须要设置regId');
-        }
-        return $this;
-    }
-
-    /**
-     * 校验参数
-     * @param false $sendAll
-     * @return $this
-     * @throws GuzzleException
-     */
-    private function checkSendAllParam()
-    {
-        // 授权token校验
-        if (!$this->_accessToken) {
-            $this->getAccessToken();
-        }
-
-        if (!$this->_appId) {
-            throw new InvalidArgumentException('VIVO推送必须要设置appId');
-        }
-        if (!$this->_appKey) {
-            throw new InvalidArgumentException('VIVO推送必须要设置appKey');
-        }
-        if (!$this->_appSecret) {
-            throw new InvalidArgumentException('VIVO推送必须要设置appSecret');
-        }
-        if (!$this->_accessToken) {
-            throw new InvalidArgumentException('VIVO推送必须要设置AccessToken');
-        }
-        if (!$this->_title) {
-            throw new InvalidArgumentException('VIVO推送必须要设置title');
-        }
-        if (!$this->_content) {
-            throw new InvalidArgumentException('VIVO推送必须要设置content');
-        }
-        if (!$this->_timeToLive) {
-            throw new InvalidArgumentException('VIVO推送必须要设置timeToLive');
-        }
         return $this;
     }
 

+ 1 - 3
app/Modules/Push/Services/PushService.php

@@ -234,9 +234,7 @@ class PushService
                     // VIVO
                     case PushConst::PROVIDER_VIVO:
                         $client = new VPush($appId, $appKey, $appSecret);
-                        $client->setPushData($title, $content, $url, []);
-                        $client->saveListPayload();
-
+                        $client->setPushData($title, $content, $url);
                         $result = $client->sendAll();
                         break;
                 }