apantle / laravel-notification-apn-http2
无需依赖的 Apple Push Notifications 提供商,可配置用于多个应用程序
0.1.3
2021-03-02 10:36 UTC
Requires
- php: ^7.2
- ext-curl: *
- ext-json: *
- illuminate/notifications: ^6.0 | ^7.0 | ^8.0
- illuminate/support: ^6.0 | ^7.0 | ^8.0
This package is auto-updated.
Last update: 2024-09-29 05:42:49 UTC
README
此包不依赖第三方依赖项,并允许使用不同的 PEM 证书和 Apple Bundle Ids 向多个应用程序发送推送。
安装
您可以通过 composer 安装此包
composer require apantle/laravel-notification-apn-http2
用法
将您的证书存储在 certificates 目录中(与 app 目录同级)
在您的通知类中实现 toApn 方法
public function toApn($notifiable): ApnHttp2Message { return ApnHttp2Message::create( $this->title, '', $this->message, [ 'customKey' => 'customData', ] ) ->setTopic($notifiable->org->topic) ->setCertificateFile($notifiable->org->ios_cert_push_file) ; }
在您的可通知模型中实现 routeNotificationForApn() 方法,返回单个设备令牌或令牌数组
public function routeNotificationForApn($notification) { return empty($notification->tokens) ? $this->devices->pluck('token') : $notification->tokens; }
配置
APN_HTTP2_PRODUCTION=true APN_HTTP2_TOPIC=work.jefrancomix.demo APN_HTTP2_CERTIFICATE=demo.pem APN_HTTP2_CERT_PASSWORD=Aw3$om3!
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件。
Laravel 包模板
此包是用 Laravel 包模板 生成的。