Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Getui.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class Getui
{
protected $app;
/**
* @var string
*/
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/sdk/IGtPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions src/sdk/igetui/template/GetuiTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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(
Expand Down