Sfoglia il codice sorgente

change:小米跳转测试;

Wang Chen 4 anni fa
parent
commit
a48230e5ac

+ 5 - 3
app/Console/Commands/Push/PushTest.php

@@ -64,11 +64,13 @@ class PushTest extends Command
 
         $title   = '这是' . $name . '标题';
         $content = '这是' . $name . '内容,创建于' . date('Y-m-d H:i:s');
-        $url     = '/views/Reader?send_order_id=1643289&bid=vdqY7p15xnZQzK4VzzgmMD6wG2yr8BNX&chapter_id=4774851';
+        $url     = '/views/Reader';
+        $params  = ['send_order_id' => 1643289, 'bid' => 'vdqY7p15xnZQzK4VzzgmMD6wG2yr8BNX', 'chapter_id' => 4774851];
         var_dump('uid:' . $uid);
         var_dump('title:' . $title);
         var_dump('content:' . $content);
         var_dump('url:' . $url);
+        var_dump('params:' . $params);
         var_dump('reg id:' . $regId);
 
         $result = [];
@@ -81,7 +83,7 @@ class PushTest extends Command
 
                     // 循环推送
                     $client->setToken($regIdList);
-                    $result = $client->sendPushMessage($title, $content, $url);
+                    $result = $client->sendPushMessage($title, $content, $url, $params);
                     break;
                 // 小米
                 case PushConst::PROVIDER_MI:
@@ -96,7 +98,7 @@ class PushTest extends Command
                 case PushConst::PROVIDER_OPPO:
                     // 初始化oppo推送
                     $client    = new OPPOPushCommon($appKey, $masterSecret);
-                    $messageId = $client->getMessageId($title, $content, $url);
+                    $messageId = $client->getMessageId($title, $content, $url, $params);
 
                     // 循环推送
                     $client->setRegArr($regIdList);

+ 7 - 6
app/Libs/Push/HuaWei/HwPushCommon.php

@@ -71,15 +71,16 @@ class HwPushCommon
 
     /**
      * 发送通知消息
-     * @param $title
-     * @param $desc
-     * @param $pageUrl
-     * @return mixed|null
+     * @param       $title
+     * @param       $desc
+     * @param       $pageUrl
+     * @param array $params
+     * @return bool|mixed|string|null
      */
-    public function sendPushMessage($title, $desc, $pageUrl)
+    public function sendPushMessage($title, $desc, $pageUrl, $params = [])
     {
         // 组装发送数据
-        $data    = $this->createFastAppConfigNotificationData($title, $desc, $pageUrl);
+        $data    = $this->createFastAppConfigNotificationData($title, $desc, $pageUrl, 0, $params);
         $message = $this->createFastAppMsg($data->getFields());
 
         # 创建app

+ 7 - 5
app/Libs/Push/OPPOPush/OPPOPushCommon.php

@@ -62,13 +62,14 @@ class OPPOPushCommon
 
     /**
      * 保存通知栏消息内容体
-     * @param $title
-     * @param $content
-     * @param $url
+     * @param       $title
+     * @param       $content
+     * @param       $url
+     * @param array $params
      * @return mixed|string
      * @throws GuzzleException
      */
-    public function getMessageId($title, $content, $url)
+    public function getMessageId($title, $content, $url, $params = [])
     {
         // 组装数据
         $pushMessage = new PushMessage();
@@ -76,7 +77,8 @@ class OPPOPushCommon
         $pushMessage->title($title);
         $pushMessage->content($content);
         $pushMessage->click_action_type(1);
-        $pushMessage->click_action_activity($url);
+        $pushMessage->click_action_activity('com.nearme.instant.action.PUSH');
+        $pushMessage->action_parameters(json_encode($params));
         $pushMessage->channel_id('OPPO PUSH');
         $pushMessage->auth_token($this->_authToken);
         $fields = $pushMessage->getData();

+ 1 - 0
app/Libs/Push/XMPush/MiPushCommon.php

@@ -77,6 +77,7 @@ class MiPushCommon
         $message->extra(Builder::intentUri, $url); // 此处设置预定义点击行为,1为打开app
         $message->extra(Builder::notifyEffect, 2); // 此处设置预定义点击行为,1为打开app 2通知栏点击后打开app的任一Activity
         $message->extra(Builder::notifyForeground, 1); // 应用在前台是否展示通知,如果不希望应用在前台时候弹出通知,则设置这个参数为0
+        $message->extra(Builder::flowControl, 3000); // 设置平滑推送, 推送速度3000每秒(qps=3000)
         $message->notifyId(2); // 通知类型。最多支持0-4 5个取值范围,同样的类型的通知会互相覆盖,不同类型可以在通知栏并存
         $message->build();
         return $message;

+ 20 - 0
app/Modules/Push/Services/PushService.php

@@ -288,9 +288,16 @@ class PushService
                         $client = new HwPushCommon($appId, $appSecret);
 
                         // 循环推送
+                        $i = 0;
                         foreach ($regIdArr as $regIdList) {
                             $client->setToken($regIdList);
                             $result = $client->sendPushMessage($title, $content, $url);
+
+                            // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
+                            $i++;
+                            if ($i % 3 === 0) {
+                                sleep(1);
+                            }
                         }
                         break;
                     // 小米
@@ -299,9 +306,16 @@ class PushService
                         $client = new MiPushCommon($package, $appSecret);
 
                         // 循环推送
+                        $i = 0;
                         foreach ($regIdArr as $regIdList) {
                             $client->setRegArr($regIdList);
                             $result = $client->sendMessage($title, $content, $url);
+
+                            // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
+                            $i++;
+                            if ($i % 3 === 0) {
+                                sleep(1);
+                            }
                         }
                         break;
                     // OPPO
@@ -311,9 +325,15 @@ class PushService
                         $messageId = $client->getMessageId($title, $content, $url);
 
                         // 循环推送
+                        $i = 0;
                         foreach ($regIdArr as $regIdList) {
                             $client->setRegArr($regIdList);
                             $result = $client->broadCastRegIds($messageId);
+                            // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
+                            $i++;
+                            if ($i % 3 === 0) {
+                                sleep(1);
+                            }
                         }
                         break;
                 }