فهرست منبع

add:推送标签;

Wang Chen 4 سال پیش
والد
کامیت
4107bada85
1فایلهای تغییر یافته به همراه103 افزوده شده و 0 حذف شده
  1. 103 0
      app/Console/Commands/Push/PushTag.php

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

@@ -0,0 +1,103 @@
+<?php
+
+
+namespace App\Console\Commands\Push;
+
+
+use App\Consts\PushConst;
+use App\Libs\Push\HuaWei\HwPushCommon;
+use App\Libs\Push\OPPOPush\OPPOPushCommon;
+use App\Libs\Push\VPush\VPush;
+use App\Libs\Push\XMPush\MiPushCommon;
+use App\Modules\Push\Models\QappPushApp;
+use App\Modules\Push\Models\QappPushUser;
+use Illuminate\Console\Command;
+
+class PushTag extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'push:tag {uid}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '推送标签';
+
+    /**
+     * @throws \GuzzleHttp\Exception\GuzzleException
+     */
+    public function handle()
+    {
+        // 用户Uid
+        $uid = $this->argument('uid');
+        
+        // 获取用户push信息
+        $pushUser     = QappPushUser::getPushUserByUid($uid);
+        $regId        = getProp($pushUser, 'reg_id');
+        $pushAppId    = getProp($pushUser, 'app_id');
+        $pushApp      = QappPushApp::getPushAppByAppId($pushAppId);
+        $package      = getProp($pushApp, 'package');
+        $appId        = getProp($pushApp, 'app_id');
+        $provider     = getProp($pushApp, 'provider');
+        $appSecret    = getProp($pushApp, 'app_secret');
+        $appKey       = getProp($pushApp, 'app_key');
+        $masterSecret = getProp($pushApp, 'master_secret');
+
+        switch ($provider) {
+            // 华为
+            case PushConst::PROVIDER_HW:
+                // 初始化huawei推送
+                $client = new HwPushCommon($appId, $appSecret);
+
+                // 循环推送
+                // $client->setToken($regIdList);
+                // $client->setFastAppTarget(1);
+                // $result = $client->sendPushMessage($title, $content, $url);
+                break;
+            // 小米
+            case PushConst::PROVIDER_MI:
+                // 初始化小米推送
+                $client = new MiPushCommon($package, $appSecret);
+
+                // 循环推送
+                // $client->setRegArr($regIdList);
+                // $result = $client->sendMessage($title, $content, $url);
+                break;
+            // OPPO
+            case PushConst::PROVIDER_OPPO:
+                // 初始化oppo推送
+                $client = new OPPOPushCommon($appKey, $masterSecret);
+
+                # 获取全部tag
+                $tags   = $client->getAllTags($regId);
+
+                // # 创建tag
+                // $client->addTags(PushConst::TOPIC_ALL, '全部用户');
+
+                // # 获取全部tag
+                // $tags2 = $client->getAllTags($regId);
+
+                dd($tags);
+                break;
+            // VIVO
+            case PushConst::PROVIDER_VIVO:
+                // 初始化oppo推送
+                $client = new VPush($appId, $appKey, $appSecret);
+
+                // 设置相关推送数据,保存消息内容(批量推送至少需要两个用户,故写死一个reg_id)
+                // $regIdList[] = '16004127020450881896432';
+                // $client->setPushData($title, $content, $url, $regIdList);
+                // $client->saveListPayload();
+
+                // // 循环推送
+                // $result = $client->sendMessage();
+                break;
+        }
+    }
+}