Wang Chen 4 gadi atpakaļ
vecāks
revīzija
77a220b6ad

+ 6 - 0
app/Console/Commands/Push/PushTag.php

@@ -93,6 +93,12 @@ class PushTag extends Command
                 // 初始化oppo推送
                 $client = new VPush($appId, $appKey, $appSecret);
 
+                $tag = PushConst::TOPIC_ALL;
+
+                $client->addTag($tag);
+
+                $client->addTagForUsers($tag, [$regId]);
+
                 // 设置相关推送数据,保存消息内容(批量推送至少需要两个用户,故写死一个reg_id)
                 // $regIdList[] = '16004127020450881896432';
                 // $client->setPushData($title, $content, $url, $regIdList);

+ 17 - 6
app/Modules/Push/Services/PushService.php

@@ -87,19 +87,30 @@ class PushService
             // 初始化push_users
             QappPushUser::initPushUser($uid, $regId, $pushAppId, $provider, $channelId);
 
+            # 推送相关变量
+            $topic        = PushConst::TOPIC_ALL;
+            $appId        = getProp($pushApp, 'app_id');
+            $appSecret    = getProp($pushApp, 'app_secret');
+            $appKey       = getProp($pushApp, 'app_key');
+            $masterSecret = getProp($pushApp, 'master_secret');
+
             // 针对华为用户需要主动订阅topic,方便后续全量推送
             if ($provider === PushConst::PROVIDER_HW) {
-                $client = new HwPushCommon($pushAppId, getProp($pushApp, 'app_secret'));
-                $client->subscribeTopic(PushConst::TOPIC_ALL, [$regId]);
+                $client = new HwPushCommon($pushAppId, $appSecret);
+                $client->subscribeTopic($topic, [$regId]);
             }
 
             // 针对OPPO用户需要主动订阅topic,方便后续全量推送
             if ($provider === PushConst::PROVIDER_OPPO) {
-                $appKey       = getProp($pushApp, 'app_key');
-                $masterSecret = getProp($pushApp, 'master_secret');
-                $client       = new OPPOPushCommon($appKey, $masterSecret);
-                $client->subscribeTags($regId, PushConst::TOPIC_ALL);
+                $client = new OPPOPushCommon($appKey, $masterSecret);
+                $client->subscribeTags($regId, $topic);
             }
+
+            // 针对VIVO用户需要主动订阅topic,方便后续全量推送
+            // if ($provider === PushConst::PROVIDER_OPPO) {
+            //     $client = new VPush($appId, $appKey, $appSecret);
+            //     $client->addTagForUsers($topic, [$regId]);
+            // }
         }
 
         // 更新用户数据库中reg_id