From 7823bf04d35e40fed0b813dab58cc30e3e0b7048 Mon Sep 17 00:00:00 2001 From: lklkdawei Date: Mon, 21 Sep 2020 16:21:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=9A=E4=B8=AAAPP=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Getui.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Getui.php b/src/Getui.php index 85573f1..7d87e0c 100644 --- a/src/Getui.php +++ b/src/Getui.php @@ -67,11 +67,11 @@ class Getui /** * Getui constructor. */ - public function __construct() + public function __construct($devise = 'basic') { $config = config('getui'); - $this->app_id = $config['basic']['app_id']; - $this->igt = new IGtPush($config['basic']['host'], $config['basic']['app_key'], $config['basic']['master_secret']); + $this->app_id = $config[$devise]['app_id']; + $this->igt = new IGtPush($config[$devise]['host'], $config[$devise]['app_key'], $config[$devise]['master_secret']); $this->is_offline = $config['push']['is_offline']; $this->offline_expire_time = $config['push']['offline_expire_time']; $this->network_type = $config['push']['network_type']; From 46c1040f36c67b75fca68012863a4a7b520514bf Mon Sep 17 00:00:00 2001 From: lklkdawei Date: Mon, 21 Sep 2020 17:07:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=9A=E4=B8=AAAPP?= =?UTF-8?q?=E6=8E=A8=E9=80=81=EF=BC=8C=E9=BB=98=E8=AE=A4=E6=98=AF=20basic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Getui.php | 21 +++++++++++++++------ src/sdk/IGtPush.php | 1 + src/sdk/igetui/template/GetuiTemplate.php | 12 ++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Getui.php b/src/Getui.php index 7d87e0c..65e145c 100644 --- a/src/Getui.php +++ b/src/Getui.php @@ -2,6 +2,9 @@ namespace Cncal\Getui; +use App\Constant\CodeInformation; +use App\Exceptions\BaseException; +use App\Widgets\SeasLog; use Cncal\Getui\Sdk\IGtPush; use Cncal\Getui\Sdk\IGetui\IGtTarget; use Cncal\Getui\Jobs\PushGetuiMessage; @@ -9,9 +12,11 @@ use Cncal\Getui\Sdk\IGetui\IGtListMessage; use Cncal\Getui\Sdk\IGetui\IGtSingleMessage; use Cncal\Getui\Sdk\IGetui\Template\GetuiTemplate; +use Illuminate\Database\QueryException; class Getui { + protected $app; /** * @var string */ @@ -67,11 +72,15 @@ class Getui /** * Getui constructor. */ - public function __construct($devise = 'basic') + public function __construct($app = 'basic') { $config = config('getui'); - $this->app_id = $config[$devise]['app_id']; - $this->igt = new IGtPush($config[$devise]['host'], $config[$devise]['app_key'], $config[$devise]['master_secret']); + if(empty($config[$app] ?? '')){ + throw new \Exception('getui app not exists'); + } + $this->app = $app; + $this->app_id = $config[$app]['app_id']; + $this->igt = new IGtPush($config[$app]['host'], $config[$app]['app_key'], $config[$app]['master_secret']); $this->is_offline = $config['push']['is_offline']; $this->offline_expire_time = $config['push']['offline_expire_time']; $this->network_type = $config['push']['network_type']; @@ -105,7 +114,7 @@ public function pushMessageToSingle($data) (int)$data['template_data']['network_type'] : $this->network_type; // todo: need to discuss - $getui_template = new GetuiTemplate($template_type, $template_data); + $getui_template = new GetuiTemplate($this->app, $template_type, $template_data); $template = $getui_template->getTemplate(); $message = new IGtSingleMessage(); @@ -160,7 +169,7 @@ public function pushMessageToList($data) $network_type = isset($data['template_data']['network_type']) ? (int)$data['template_data']['network_type'] : $this->network_type; - $getui_template = new GetuiTemplate($template_type, $template_data); + $getui_template = new GetuiTemplate($this->app, $template_type, $template_data); $template = $getui_template->getTemplate(); $message = new IGtListMessage(); @@ -221,7 +230,7 @@ public function pushMessageToApp($data) (int)$data['template_data']['network_type'] : $this->network_type; // todo: need to discuss - $getui_template = new GetuiTemplate($template_type, $template_data); + $getui_template = new GetuiTemplate($this->app, $template_type, $template_data); $template = $getui_template->getTemplate(); $message = new IGtAppMessage(); diff --git a/src/sdk/IGtPush.php b/src/sdk/IGtPush.php index ecbaad8..8014f82 100644 --- a/src/sdk/IGtPush.php +++ b/src/sdk/IGtPush.php @@ -153,6 +153,7 @@ public function pushMessageToSingle($message, $target, $requestId = null) } $params = $this->getSingleMessagePostData($message, $target, $requestId); + print_r($params); return $this->httpPostJSON($this->host, $params); } diff --git a/src/sdk/igetui/template/GetuiTemplate.php b/src/sdk/igetui/template/GetuiTemplate.php index b67e3e0..b1d1370 100644 --- a/src/sdk/igetui/template/GetuiTemplate.php +++ b/src/sdk/igetui/template/GetuiTemplate.php @@ -59,11 +59,11 @@ class GetuiTemplate * @param $type * @param $template_data */ - public function __construct($type, $template_data) + public function __construct($app, $type, $template_data) { $config = config('getui'); - $this->app_id = $config['basic']['app_id']; - $this->app_key = $config['basic']['app_key']; + $this->app_id = $config[$app]['app_id']; + $this->app_key = $config[$app]['app_key']; $this->is_ring = $config['push']['is_ring']; $this->is_vibrate = $config['push']['is_vibrate']; $this->is_clearable = $config['push']['is_clearable']; @@ -183,9 +183,9 @@ private function IGtNotyPopLoadTemplate() $template->set_isAutoInstall(isset($is_auto_install) ? (boolean)$is_auto_install : false); $template->set_isActived(isset($is_actived) ? (boolean)$is_actived : false); - $template->set_isRing(isset($is_ring) ? (boolean)$is_ring : $this->is_ring); - $template->set_isVibrate(isset($is_vibrate) ? (boolean)$is_vibrate : $this->is_vibrate); - $template->set_isClearable(isset($is_clearable) ? (boolean)$is_clearable : $this->is_clearable); + $template->set_isBelled(isset($is_ring) ? (boolean)$is_ring : $this->is_ring); + $template->set_isVibrationed(isset($is_vibrate) ? (boolean)$is_vibrate : $this->is_vibrate); + $template->set_isCleared(isset($is_clearable) ? (boolean)$is_clearable : $this->is_clearable); if (isset($begin_at) && isset($end_at)) { $template->set_duration( From 60159563c06127debe05368290b6aa6ea8b2aa4c Mon Sep 17 00:00:00 2001 From: lklkdawei Date: Mon, 21 Sep 2020 17:10:07 +0800 Subject: [PATCH 3/3] 1 --- src/Getui.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Getui.php b/src/Getui.php index 65e145c..c594d32 100644 --- a/src/Getui.php +++ b/src/Getui.php @@ -2,9 +2,6 @@ namespace Cncal\Getui; -use App\Constant\CodeInformation; -use App\Exceptions\BaseException; -use App\Widgets\SeasLog; use Cncal\Getui\Sdk\IGtPush; use Cncal\Getui\Sdk\IGetui\IGtTarget; use Cncal\Getui\Jobs\PushGetuiMessage; @@ -12,7 +9,6 @@ use Cncal\Getui\Sdk\IGetui\IGtListMessage; use Cncal\Getui\Sdk\IGetui\IGtSingleMessage; use Cncal\Getui\Sdk\IGetui\Template\GetuiTemplate; -use Illuminate\Database\QueryException; class Getui {