byrontudhope / pushnotificationlaravel
Laravel 5 包,用于向 Android 和 iOS 设备发送推送通知
v1.1.3
2017-02-13 10:28 UTC
Requires
- php: >=5.4.0
- illuminate/support: 5.0.* | 5.1.* | 5.2.* | 5.3.* | 5.4.*
- sly/notification-pusher: 2.x
This package is not auto-updated.
Last update: 2024-09-14 19:04:06 UTC
README
基于 https://github.com/davibennun/laravel-push-notification,支持 Laravel 5 和 5.1。
安装
更新您的 composer.json
文件,将其作为依赖项包含
"byrontudhope/pushnotificationlaravel": "dev-master"
通过在 config/app.php
文件中添加它,注册 PushNotification 服务提供者。
'providers' => array( 'ByronTudhope\LaravelPushNotification\PushNotificationServiceProvider' )
通过在 config/app.php
文件中添加它,将 PushNotification 门面别名化。
'aliases' => array( 'PushNotification' => 'ByronTudhope\LaravelPushNotification\PushNotification', )
配置
通过运行以下命令将配置文件复制到您的项目中
php artisan vendor:publish
这将生成一个类似于下面的配置文件
array( 'iOS' => [ 'environment' => env('IOS_PUSH_ENV', 'development'), 'certificate' => env('IOS_PUSH_CERT', __DIR__ . '/ios-push-notification-certificates/development/'), 'passPhrase' => env('IOS_PUSH_PASSWORD', '291923Job'), 'service' => 'apns' ], 'android' => [ 'environment' => env('ANDROID_PUSH_ENV', 'development'), 'apiKey' => env('ANDROID_PUSH_API_KEY', 'yourAPIKey'), 'service' => 'gcm' ] );
其中所有第一级键对应于服务配置,每个服务都有其自己的属性,例如,Android 使用 apiKey
,而 iOS 使用 certificate
和 passPhrase
。您可以设置任意数量的服务配置,每个应用程序一个。将在配置文件夹中添加一个名为 'ios-push-notification-certificates' 的目录,以存储开发和生产证书。
别忘了设置 service
键来识别 iOS('service'=>'apns')和 Android('service'=>'gcm')
用法
PushNotification::app('iOS') ->to($deviceToken) ->send('Hello World, i`m a push message');