laravel-notification-channels / ionic-push-notifications
此包已被废弃,不再维护。未建议替代包。
Ionic 推送通知驱动程序
1.0.5
2017-07-22 19:27 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- illuminate/notifications: 5.3.*|5.4.*|5.5.*
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/database: 3.3.x-dev
- orchestra/testbench: 3.3.x-dev
- phpunit/phpunit: 4.*
README
****************************************************************************************
Ionic Cloud 已于 2018 年 1 月 31 日弃用,因此此包也被弃用。详情请见此处
****************************************************************************************
Ionic Push Notifications Channel for Laravel
此包使得使用 Laravel 发送 Ionic Push Notifications 变得简单。
内容
安装
您可以通过 composer 安装此包
composer require laravel-notification-channels/ionic-push-notifications
设置 Ionic Push 服务
将您的 Ionic Push 身份验证令牌添加到 config/services.php
// config/services.php 'ionicpush' => [ 'key' => env('IONIC_PUSH_API_KEY'), ]
使用方法
现在您可以在通知内部的 via() 方法中使用此通道
use NotificationChannels\IonicPushNotifications\IonicPushChannel; use NotificationChannels\IonicPushNotifications\IonicPushMessage; use Illuminate\Notifications\Notification; class FriendRequest extends Notification { public function via($notifiable) { return [IonicPushChannel::class]; } public function toIonicPush($notifiable) { return IonicPushMessage::create('my-security-profile') ->title('Your title') ->message('Your message') ->sound('ping.aiff') ->payload(['foo' => 'bar']); } }
您可以为 iOS 和 Android 单独设置不同的设置,如下所示...
use NotificationChannels\IonicPushNotifications\IonicPushChannel; use NotificationChannels\IonicPushNotifications\IonicPushMessage; use Illuminate\Notifications\Notification; class FriendRequest extends Notification { public function via($notifiable) { return [IonicPushChannel::class]; } public function toIonicPush($notifiable) { return IonicPushMessage::create('my-security-profile') ->iosMessage('Your iOS message') ->androidMessage('Your Android message') ->iosSound('ping.aiff') ->androidSound('ping.aiff'); } }
为了让您的通知知道发送给哪个设备令牌,将 routeNotificationForIonicPush 方法添加到您的 Notifiable 模型中。
此方法需要返回用户的设备令牌(或用户的 Ionic Auth 电子邮件地址,或用户的 Ionic userID)。如果需要,请勿忘记设置带有 sendTo() 的目标用户的方法(见下文)。
public function routeNotificationForIonicPush() { return $this->device_token; }
您还可以返回多个令牌以发送给用户可能拥有的多个设备
public function routeNotificationForIonicPush() { return $this->device_tokens; }
可用的消息方法
create(): 接受your-security-profile的字符串值。title(): 您通知的标题(适用于所有平台)。可以由特定平台的title方法覆盖(见下文)。message(): 您通知的消息内容(适用于所有平台)。可以由特定平台的message方法覆盖(见下文)。sound(): 您通知的标题(适用于所有平台)。可以由特定平台的sound方法覆盖(见下文)。payload(): 要与您的通知一起发送的数据数组。可以由特定平台的payload方法覆盖(见下文)。scheduled(): 为未来的交付安排通知。接受DateTime对象或日期字符串。sendTo(): 设置目标用户的方法 -令牌(默认)、user_ids 或电子邮件。
特定于 iOS 的方法
查看此处 以获取这些方法的完整详细信息。
iosMessage()iosTitle()iosBadge()iosPayload()iosSound()iosPriority()iosExpire()iosContentAvailable()
Android 特定方法
查看此处 以获取这些方法的完整详细信息。
androidCollapseKey()androidContentAvailable()androidData()androidDelayWhileIdle()androidIcon()androidIconColor()androidMessage()androidPriority()androidSound()androidTag()androidTimeToLive()androidTitle()
变更日志
请参阅 CHANGELOG 了解最近更改的内容。
测试
$ composer test
安全
如果您发现任何安全问题,请发送电子邮件至 m@rkbee.ch 而不是使用问题跟踪器。
贡献
请参阅 CONTRIBUTING 以获取详细信息。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 以获取更多信息。