Merge pull request #9 from ilovintit/main

增加goPush连接参数配置
This commit is contained in:
Easy 2022-01-05 22:43:22 +08:00 committed by GitHub
commit 1ba0b87314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -50,3 +50,9 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
GO_PUSH_ADDRESS=127.0.0.1
GO_PUSH_IOS_PORT=8888
GO_PUSH_IOS_TOPIC=com.pushdeer.app.ios
GO_PUSH_IOS_CLIP_PORT=8889
GO_PUSH_IOS_CLIP_TOPIC=com.pushdeer.app.ios.Clip

View File

@ -64,18 +64,17 @@ function ios_send($is_clip, $device_token, $text, $desp = '', $dev = true)
$notification->production = true;
}
$port = intval($is_clip) == 1 ? 8889 : 8888;
$topic = intval($is_clip) == 1 ? 'com.pushdeer.app.ios.Clip' : 'com.pushdeer.app.ios';
$port = intval($is_clip) == 1 ? config('services.go_push.ios_clip_port') : config('services.go_push.ios_port');
$topic = intval($is_clip) == 1 ? config('services.go_push.ios_clip_topic') : config('services.go_push.ios_topic');
$notification->topic = $topic;
$notification->sound = ['volume'=>2.0];
$json = ['notifications'=>[$notification]];
$client = new GuzzleHttp\Client();
$response = $client->post('http://127.0.0.1:'. $port .'/api/push', [
$response = $client->post('http://'.config('services.go_push.address').':'. $port .'/api/push', [
GuzzleHttp\RequestOptions::JSON => $json
]);
$ret = $response->getBody()->getContents();
error_log('push error'. $ret);
return $ret;
;
}

View File

@ -30,4 +30,12 @@ return [
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'go_push' => [
'address' => env('GO_PUSH_ADDRESS', '127.0.0.1'),
'ios_port' => env('GO_PUSH_IOS_PORT', 8888),
'ios_topic' => env('GO_PUSH_IOS_TOPIC', 'com.pushdeer.app.ios'),
'ios_clip_port' => env('GO_PUSH_IOS_CLIP_PORT', 8889),
'ios_clip_topic' => env('GO_PUSH_IOS_CLIP_TOPIC', 'com.pushdeer.app.ios.Clip')
]
];