承接 firegon/laravel-expo-notifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

firegon/laravel-expo-notifier

最新稳定版本:0.0.1

Composer 安装命令:

composer require firegon/laravel-expo-notifier

包简介

Easily send Expo notifications with Laravel.

README 文档

README

Easily manage Expo notifications with Laravel. Support batched notifications.

Latest Version GitHub Workflow Status Total Downloads

Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.

Installation

composer require yieldstudio/laravel-expo-notifier

Configure

You must publish the configuration file with:

php artisan vendor:publish --provider="YieldStudio\LaravelExpoNotifier\ExpoNotificationsServiceProvider" --tag="expo-notifications-config" --tag="expo-notifications-migration"

Available environment variables

Usage

Add relation for notifiable class

In order to use Notification, you need to declare the relation expoTokens on your Notifiable class. Two Trait are available to help you :

  • HasUniqueExpoToken if your notifiable class can have only one expo token
  • HasManyExpoToken if your notifiable class can have many expo token

Send notification

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use YieldStudio\LaravelExpoNotifier\ExpoNotificationsChannel;
use YieldStudio\LaravelExpoNotifier\Dto\ExpoMessage;

class NewSampleNotification extends Notification
{
    public function via($notifiable): array
    {
        return [ExpoNotificationsChannel::class];
    }

    public function toExpoNotification($notifiable): ExpoMessage
    {
        return (new ExpoMessage())
            // ->to($notifiable->expoTokens->pluck('value')->toArray()) if using HasManyExpoToken
            ->to([$notifiable->expoTokens->value])
            ->notifiable($notifiable) // allow possibility to store the receiver of the notification
            ->title('A beautiful title')
            ->body('This is a content')
            ->channelId('default');
    }
}

Commands usage

Send database pending notifications

php artisan expo:notifications:send

Clean sent notification from database

php artisan expo:notifications:clear

Clean tickets from outdated tokens

php artisan expo:tickets:check

You may create schedules to execute these commands.

Batch support

You can send notification in the next batch :

(new ExpoMessage())
    ->to([$notifiable->expoTokens->value])
    ->title('A beautiful title')
    ->body('This is a content')
    ->channelId('default')
    ->shouldBatch();

Don't forget to schedule the expo:notifications:send command.

Unit tests

To run the tests, just run composer install and composer test.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail contact@yieldstudio.fr instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 861
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-29