diff --git a/src/Getui.php b/src/Getui.php index 85573f1..c594d32 100644 --- a/src/Getui.php +++ b/src/Getui.php @@ -12,6 +12,7 @@ class Getui { + protected $app; /** * @var string */ @@ -67,11 +68,15 @@ class Getui /** * Getui constructor. */ - public function __construct() + public function __construct($app = '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']); + 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 +110,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 +165,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 +226,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(