mxp100 / pusher
PHP 推送通知至 APNS, FCM
2.1
2019-11-26 13:44 UTC
Requires
- php: ^7.1
- ext-curl: *
- ext-json: >=1.3.7
Suggests
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-25 00:35:38 UTC
README
兼容性: PHP 7+
安装
Composer
composer require mxp100/pusher
APNS 证书生成
请参阅Wiki: https://github.com/mxp100/Pusher/wiki/Generating-the-Apple-Push-Notification-SSL-certificate-on-Mac
示例
FCM 示例
$serverKey = '[server key]'; $deviceId = '[device token]'; $devices = new DeviceCollection([new Device($deviceId)]); $message = new Message('This is a test message'); $adapter = new Fcm($serverKey); $pusher = new Pusher([new Push($adapter, $devices, $message)]); $pusher->push();
GCM 示例
$serverKey = '[path to certification]'; $deviceId = '[device token]'; $devices = new DeviceCollection([new Device($deviceId)]); $message = new Message('This is a test message'); $adapter = new Gcm($serverKey, AdapterInterface::ENVIRONMENT_DEVELOPMENT); $pusher = new Pusher([new Push($adapter, $devices, $message)]); $pusher->push();
APNS 示例
$serverKey = '[path to certification]'; $deviceId = '[device token]'; $devices = new DeviceCollection([new Device($deviceId)]); $message = new Message('This is a test message'); $adapter = new Apns($serverKey, AdapterInterface::ENVIRONMENT_DEVELOPMENT); $pusher = new Pusher([new Push($adapter, $devices, $message)]); $pusher->push();