| xqd
@@ -3,15 +3,15 @@ namespace App\Helper;
|
|
|
|
|
|
use JPush\Client as JPush;
|
|
|
use App\Models\UserInfoModel;
|
|
|
-use App\User;
|
|
|
|
|
|
trait JpushHelper
|
|
|
{
|
|
|
- public function jPush($title,$content='',$userid=0) {
|
|
|
+ public function jPush($title,$content='',$userid=0,$type=0,$id=0) {
|
|
|
$app_key = '69838317211448192366f9d8';
|
|
|
$master_secret = 'f202d10301151e1816b49e55';
|
|
|
$client = new JPush($app_key, $master_secret, storage_path('logs/jpush.log'));
|
|
|
|
|
|
+ \Log::info('jpush start!');
|
|
|
// $push = new Push;
|
|
|
// $push->title = $title;
|
|
|
// $push->content = $content;
|
| xqd
@@ -30,6 +30,24 @@ trait JpushHelper
|
|
|
$pusher->setPlatform(['ios', 'android']);
|
|
|
// $pusher->addAllAudience();
|
|
|
$pusher->addRegistrationId($regId);
|
|
|
+ if($type!=0&&$id!=0){
|
|
|
+ $pusher->androidNotification($title,[
|
|
|
+ 'title' => $content,
|
|
|
+ 'content_type' => 'text',
|
|
|
+ 'extras' => [
|
|
|
+ 'type' => 1,
|
|
|
+ 'id' => 2,
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ $pusher->iosNotification($title, [
|
|
|
+ 'sound' => 'sound',
|
|
|
+ 'badge' => '+1',
|
|
|
+ 'extras' => [
|
|
|
+ 'type' => 1,
|
|
|
+ 'id' => 2,
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
$pusher->setNotificationAlert($title);
|
|
|
$pusher->options($options);
|
|
|
$pusher->send();
|