subit/expo-laravel
Composer 安装命令:
composer require subit/expo-laravel
包简介
Expo notifications driver for Laravel
README 文档
README
Contents
Installation
You can install the package via composer:
composer require subit/expo-laravel
This package supports Laravel 10-13 and will automatically register itself using Package Discovery.
You can publish the migration with:
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="migrations"
After publishing the migration you can create the expo_notification_recipients table by running the migrations:
php artisan migrate
You can optionally publish the config file with:
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'recipients' => [ /* * Supported: "database" */ 'driver' => env('EXPONENT_PUSH_NOTIFICATION_RECIPIENTS_STORAGE_DRIVER', 'file'), 'database' => [ 'table_name' => 'expo_notification_recipients', ], ] ];
Usage
use NotificationChannels\ExpoPushNotifications\ExpoChannel; use NotificationChannels\ExpoPushNotifications\ExpoMessage; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [ExpoChannel::class]; } public function toExpoPush($notifiable) { return ExpoMessage::create() ->badge(1) ->enableSound() ->title("Congratulations!") ->body("Your {$notifiable->service} account was approved!"); } }
ExpoMessage options
| Property | iOS/Android | Type | Description |
|---|---|---|---|
to() |
both | string | An Expo push token specifying the recipient of this message |
jsonData() |
both | string | A JSON object delivered to your app. It may be up to 4KiB |
title() |
both | string | The title to display in the notification |
body() |
both | string | The message to display in the notification |
ttl() |
both | int | Seconds the message may be kept around for redelivery |
expiration() |
both | int | UNIX epoch timestamp. Same effect as ttl. ttl takes precedence |
priority() |
both | Priority | The delivery priority of the message |
subtitle() |
iOS | string | The subtitle to display in the notification below the title |
enableSound() |
iOS | Play a sound when the recipient receives this notification | |
disableSound() |
iOS | Play no sound (default) | |
badge() |
iOS | int | Number to display in the badge on the app icon |
channelId() |
Android | string | Channel through which to display this notification |
For a more detailed description, refer to the Expo documentation https://docs.expo.io/versions/latest/guides/push-notifications/#formats
Managing Recipients
This package registers two endpoints that handle the subscription of recipients, the endpoints are defined in src/Http/routes.php file, used by ExpoController and all loaded through the package service provider.
Routing a message
By default the expo "recipient" messages will be sent to will be defined (besides the id) using the notifiable class as type, for example App\User. However, you can change this behaviour by including a routeNotificationForExpoPushNotifications() in the notifiable class method that returns the recipient type.
subit/expo-laravel 适用场景与选型建议
subit/expo-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.62k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 subit/expo-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 subit/expo-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-14