diff --git a/api/.env.example b/api/.env.example index f4b4447..0330b41 100644 --- a/api/.env.example +++ b/api/.env.example @@ -56,3 +56,6 @@ 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 + +ANDROID_PACKAGE=com.pushdeer.app.quick.v2 +MIPUSH_SECRET=NONE diff --git a/api/app/Http/Controllers/PushDeerMessageController.php b/api/app/Http/Controllers/PushDeerMessageController.php index aea8e85..2d702ef 100644 --- a/api/app/Http/Controllers/PushDeerMessageController.php +++ b/api/app/Http/Controllers/PushDeerMessageController.php @@ -79,7 +79,10 @@ class PushDeerMessageController extends Controller foreach ($devices as $device) { if ($device) { - $result[] = ios_send($device->is_clip, $device->device_id, $validated['text'], '', env('APP_DEBUG')); + $func_name = $device['type'].'_send'; + if (function_exists($func_name)) { + $result[] = $func_name($device->is_clip, $device->device_id, $validated['text'], '', env('APP_DEBUG')); + } } } } diff --git a/api/app/Http/Helpers.php b/api/app/Http/Helpers.php index bb84592..d1fc09b 100644 --- a/api/app/Http/Helpers.php +++ b/api/app/Http/Helpers.php @@ -1,4 +1,14 @@ title($text); // 通知栏的title + $message1->description($desp); // 通知栏的descption + $message1->passThrough(0); // 这是一条通知栏消息,如果需要透传,把这个参数设置成1,同时去掉title和descption两个参数 + // $message1->payload($payload); // 携带的数据,点击后将会通过客户端的receiver中的onReceiveMessage方法传入。 + $message1->extra(Builder::notifyForeground, 1); // 应用在前台是否展示通知,如果不希望应用在前台时候弹出通知,则设置这个参数为0 + $message1->notifyId(2); // 通知类型。同样的类型的通知会互相覆盖,不同类型可以在通知栏并存 + $message1->build(); + + $sender = android_sender(); + return $sender->send($message1, $device_token)->getRaw(); +} + function ios_send($is_clip, $device_token, $text, $desp = '', $dev = true) { $notification = new stdClass(); diff --git a/api/composer.json b/api/composer.json index dfd5b59..10a1adf 100644 --- a/api/composer.json +++ b/api/composer.json @@ -11,7 +11,8 @@ "guzzlehttp/guzzle": "^7.4", "laravel/framework": "^8.65", "laravel/sanctum": "^2.11", - "laravel/tinker": "^2.5" + "laravel/tinker": "^2.5", + "rookiejin/mipush": "^1.0" }, "require-dev": { "facade/ignition": "^2.5", diff --git a/api/composer.lock b/api/composer.lock index f7b0965..c21e981 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "08199d4bca4a00de977a73bdcd9ea318", + "content-hash": "0f637f60000aed6893b5527dc426032b", "packages": [ { "name": "asm89/stack-cors", @@ -2897,6 +2897,49 @@ ], "time": "2021-09-25T23:10:38+00:00" }, + { + "name": "rookiejin/mipush", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/rookiejin/mipush.git", + "reference": "90c7b856fbff73fca3e88040972a3f57ce7acc3d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rookiejin/mipush/zipball/90c7b856fbff73fca3e88040972a3f57ce7acc3d", + "reference": "90c7b856fbff73fca3e88040972a3f57ce7acc3d", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "type": "library", + "autoload": { + "psr-4": { + "Rookiejin\\Xmpush\\": "src/xmpush" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mj", + "email": "Mj@mj.com" + } + ], + "description": "小米推送官方包,https://dev.mi.com/console/doc/detail?pId=230,PHP 2.2.20版 于2017.06.13更新", + "support": { + "issues": "https://github.com/rookiejin/mipush/issues", + "source": "https://github.com/rookiejin/mipush/tree/master" + }, + "time": "2018-01-22T08:21:53+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.3.0", @@ -7952,5 +7995,5 @@ "php": "^7.3|^8.0" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" }