|
@@ -1,5 +1,6 @@
|
|
|
<?php
|
|
|
// 接口公共方法
|
|
|
+use app\common\model\UserMessage;
|
|
|
use think\Db;
|
|
|
use JPush\Client;
|
|
|
require_once env('root_path').'vendor/jpush/jpush/autoload.php';
|
|
@@ -73,8 +74,46 @@ function get_calendar($day = 7,$type='asc'){
|
|
|
if($type == 'asc') array_multisort(array_column($data,'time_int'),SORT_ASC,$data);
|
|
|
return $data;
|
|
|
}
|
|
|
+function jg_push()
|
|
|
+{
|
|
|
+ $user_id = 65 ;
|
|
|
+ $alert ='aaa';
|
|
|
+ if(empty($user_id)) return false;
|
|
|
+ $appKey = '02a7faefd91c8a6a446a6a14';
|
|
|
+ $masterSecret = 'ba2e100db997024d9b6e5d35';
|
|
|
+ $client = new Client($appKey, $masterSecret,null);
|
|
|
+ $push_payload = $client->push()
|
|
|
+ ->setPlatform(array('ios', 'android'))
|
|
|
+ ->addAlias(strval($user_id))
|
|
|
+ ->iosNotification($alert, array(
|
|
|
+ 'badge' => '+1',
|
|
|
+ 'content-available' => true,
|
|
|
+ 'mutable-content' => true,
|
|
|
+ 'category' => 'jiguang',
|
|
|
+ 'extras' => array(
|
|
|
+ 'key' => 'value',
|
|
|
+ 'jiguang'
|
|
|
+ ),
|
|
|
+ ))->androidNotification($alert, array(
|
|
|
+ 'title' => '消息通知',
|
|
|
+ // 'builder_id' => 2,
|
|
|
+ 'extras' => array(
|
|
|
+ 'key' => 'value',
|
|
|
+ 'jiguang'
|
|
|
+ ),
|
|
|
+ ))->options(array(
|
|
|
+ 'apns_production' => True,
|
|
|
+ ));
|
|
|
+ try {
|
|
|
+ $response = $push_payload->send();
|
|
|
+ return $response;
|
|
|
+ } catch (\JPush\Exceptions\APIConnectionException $e) {
|
|
|
+ return $e;
|
|
|
+ } catch (\JPush\Exceptions\APIRequestException $e) {
|
|
|
+ return $e;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+}
|
|
|
|
|
|
|
|
|
|