|
@@ -21,7 +21,9 @@ class Getui
|
|
|
}
|
|
|
|
|
|
//创建消息
|
|
|
- public function sendtoall($title, $body, $type = 1){
|
|
|
+ //type = 1 安卓
|
|
|
+ //type = 2 苹果
|
|
|
+ public function sendtoall($title, $body, $type = 1,$platform = 'android'){
|
|
|
if (!$access_token = $this->auth()) {
|
|
|
return $this->error('ge tui token error');
|
|
|
}
|
|
@@ -30,7 +32,7 @@ class Getui
|
|
|
$notification = [
|
|
|
"notification"=> [
|
|
|
"title"=> $title,
|
|
|
- "body"=> $body,
|
|
|
+ "body" => $body,
|
|
|
"click_type"=> "url",
|
|
|
"url"=> "https//:xxx"
|
|
|
],
|
|
@@ -40,7 +42,7 @@ class Getui
|
|
|
$transmission = [
|
|
|
'transmission' => json_encode([
|
|
|
"title"=> $title,
|
|
|
- "body"=> $body,
|
|
|
+ "body" => $body,
|
|
|
"t" => time(),
|
|
|
]),
|
|
|
];
|
|
@@ -52,6 +54,30 @@ class Getui
|
|
|
$push_message = $transmission;
|
|
|
}
|
|
|
|
|
|
+ $push_channel = [];
|
|
|
+ if ($platform == 'ios') {
|
|
|
+ $push_channel = [
|
|
|
+ "ios" => [
|
|
|
+ "type" => "notify",
|
|
|
+ "payload" => json_encode([
|
|
|
+ "title" => $title,
|
|
|
+ "body" => $body,
|
|
|
+ ], JSON_UNESCAPED_UNICODE),
|
|
|
+ "aps" => [
|
|
|
+ "alert" => [
|
|
|
+ "title" => $title,
|
|
|
+ "body" => $body,
|
|
|
+ ],
|
|
|
+ "content-available" => 0,
|
|
|
+ "sound" => "default",
|
|
|
+ "category" => "ACTIONABLE",
|
|
|
+ ],
|
|
|
+ "auto_badge" => "+1",
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $push_message = $transmission;
|
|
|
+ }
|
|
|
+
|
|
|
$data = [
|
|
|
"request_id"=> createUniqueNo('PA'),
|
|
|
"group_name"=> "",
|
|
@@ -61,6 +87,10 @@ class Getui
|
|
|
"audience"=> "all",
|
|
|
"push_message"=> $push_message,
|
|
|
];
|
|
|
+ if ($platform == 'ios') {
|
|
|
+ $data['push_channel'] = $push_channel;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
$response = $this->post('/push/all', $data, [
|
|
|
'token:'.$access_token
|
|
@@ -86,7 +116,6 @@ class Getui
|
|
|
if (!$access_token = $this->auth()) {
|
|
|
return $this->error('ge tui token error');
|
|
|
}
|
|
|
- dump($access_token);
|
|
|
// 通知
|
|
|
$notification = [
|
|
|
"notification" => [
|
|
@@ -209,7 +238,6 @@ class Getui
|
|
|
$common_header = ["Content-Type:application/json;charset=UTF-8","Connection: Keep-Alive"];
|
|
|
$header = array_merge($header,$common_header);
|
|
|
|
|
|
- dump($header);
|
|
|
$url = $this->base_uri.$this->appId.$uri;
|
|
|
return curl_post($url,json_encode($params),$header);
|
|
|
}
|