PHPackages                             laravel-notification-channels/expo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. laravel-notification-channels/expo

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

laravel-notification-channels/expo
==================================

Expo Notifications Channel for Laravel

v2.2.0(2mo ago)64426.3k—7.8%20[1 issues](https://github.com/laravel-notification-channels/expo/issues)1MITPHPPHP ^8.3CI passing

Since Jan 18Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/laravel-notification-channels/expo)[ Packagist](https://packagist.org/packages/laravel-notification-channels/expo)[ Docs](https://github.com/laravel-notification-channels/expo)[ RSS](/packages/laravel-notification-channels-expo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (16)Versions (13)Used By (1)

[![Social Card of Laravel Expo Channel](https://github.com/laravel-notification-channels/expo/raw/main/art/socialcard.png?raw=true)](https://github.com/laravel-notification-channels/expo/blob/main/art/socialcard.png?raw=true)

Expo Notifications Channel
==========================

[](#expo-notifications-channel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d9f24aa2ce11bfa0daac1abd7e0842f3636fae17ecc756db7cba7ce405a9ef2e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6578706f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/expo)[![GitHub Tests Action Status](https://camo.githubusercontent.com/165d3f3b261aece98cd158df928b3ce399b15e63d5523a1d6144d100bf45de04/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6578706f2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://github.com/laravel-notification-channels/expo/actions?query=workflow%3ATests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c8221453858362b3ab294fe215c1a2550bba72f89285be153fc36747de2e960c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6578706f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/expo)

[Expo](https://docs.expo.dev/push-notifications/overview/) channel for pushing notifications to your React Native apps.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Additional Security](#additional-security-optional)
- [Usage](#usage)
- [Expo Message Request Format](#expo-message-request-format)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require laravel-notification-channels/expo
```

Additional Security (optional)
------------------------------

[](#additional-security-optional)

You can require any push notifications to be sent with an additional [Access Token](https://docs.expo.dev/push-notifications/sending-notifications/#additional-security) before Expo delivers them to your users.

If you want to make use of this additional security layer, add the following to your `config/services.php` file:

```
'expo' => [
    'access_token' => env('EXPO_ACCESS_TOKEN'),
],
```

Usage
-----

[](#usage)

You can now use the `expo` channel in the `via()` method of your `Notification`s.

### Notification / `ExpoMessage`

[](#notification--expomessage)

First things first, you need to have a [Notification](https://laravel.com/docs/9.x/notifications) that needs to be delivered to someone. Check out the [Laravel documentation](https://laravel.com/docs/9.x/notifications#generating-notifications) for more information on generating notifications.

```
use NotificationChannels\Expo\ExpoMessage;

class SuspiciousActivityDetected extends Notification
{
    public function toExpo($notifiable): ExpoMessage
    {
        return ExpoMessage::create('Suspicious Activity')
            ->body('Someone tried logging in to your account!')
            ->data($notifiable->only('email', 'id'))
            ->expiresAt(now()->addHour())
            ->priority('high')
            ->playSound();
    }

    public function via($notifiable): array
    {
        return ['expo'];
    }
}
```

Note

Detailed explanation regarding the Expo Message Request Format can be found [here](#expo-message-request-format).

You can also apply conditionals to `ExpoMessage` without breaking the method chain:

```
use NotificationChannels\Expo\ExpoMessage;

public function toExpo($notifiable): ExpoMessage
{
    return ExpoMessage::create('Suspicious Activity')
        ->body('Someone tried logging in to your account!')
        ->when($notifiable->wantsSound(), fn ($msg) => $msg->playSound())
        ->unless($notifiable->isVip(), fn ($msg) => $msg->normal(), fn ($msg) => $msg->high());
}
```

### Notifiable / `ExpoPushToken`

[](#notifiable--expopushtoken)

Next, you will have to set a `routeNotificationForExpo()` method in your `Notifiable` model.

#### Unicasting (single device)

[](#unicasting-single-device)

The method **must** return either an instance of `ExpoPushToken` or `null`. An example:

```
use NotificationChannels\Expo\ExpoPushToken;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Get the attributes that should be cast.
     *
     * @return array
     */
    protected function casts(): array
    {
        return [
            'expo_token' => ExpoPushToken::class
        ];
    }

    public function routeNotificationForExpo(): ?ExpoPushToken
    {
        return $this->expo_token;
    }
}
```

Important

No notifications will be sent in case of `null`.

Note

More info regarding the model cast can be found [here](#model-casting).

#### Multicasting (multiple devices)

[](#multicasting-multiple-devices)

The method **must** return an `array` or `Collection`, the specific implementation depends on your use case. An example:

```
use Illuminate\Database\Eloquent\Collection;

class User extends Authenticatable
{
    use Notifiable;

    /**
    * @return Collection
    */
    public function routeNotificationForExpo(): Collection
    {
        return $this->devices->pluck('expo_token');
    }
}
```

Important

No notifications will be sent in case of an empty `Collection`.

### Sending

[](#sending)

Once everything is in place, you can simply send a notification by calling:

```
$user->notify(new SuspiciousActivityDetected());
```

### Validation

[](#validation)

You ought to have an HTTP endpoint that associates a given `ExpoPushToken` with an authenticated `User` so that you can deliver push notifications. For this reason, we're also providing a custom validation `ExpoPushTokenRule` class which you can use to protect your endpoints. An example:

```
use NotificationChannels\Expo\ExpoPushToken;

class StoreDeviceRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'device_id' => ['required', 'string', 'min:2', 'max:255'],
            'token' => ['required', ExpoPushToken::rule()],
        ];
    }
}
```

### Model casting

[](#model-casting)

The `ExpoChannel` expects you to return an instance of `ExpoPushToken` from your `Notifiable`s. You can easily achieve this by applying the `ExpoPushToken` as a custom model cast. An example:

```
use NotificationChannels\Expo\ExpoPushToken;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Get the attributes that should be cast.
     *
     * @return array
     */
    protected function casts(): array
    {
        return [
            'expo_token' => ExpoPushToken::class
        ];
    }
}
```

This custom value object guarantees the integrity of the push token. You should make sure that [only valid tokens](#validation) are saved.

### Handling failed deliveries

[](#handling-failed-deliveries)

Unfortunately, Laravel does not provide an [OOB solution](https://github.com/laravel-notification-channels/channels/issues/16) for handling failed deliveries. However, there is a `NotificationFailed` event which Laravel does provide so you can hook into failed delivery attempts. This is particularly useful when an old token is no longer valid and the service starts responding with `DeviceNotRegistered` errors.

You can register an event listener that listens to this event and handles the appropriate errors. An example:

```
use Illuminate\Notifications\Events\NotificationFailed;

class HandleFailedExpoNotifications
{
    public function handle(NotificationFailed $event)
    {
        if ($event->channel !== 'expo') return;

        /** @var ExpoError $error */
        $error = $event->data;

        // Remove old token
        if ($error->type->isDeviceNotRegistered()) {
            $event->notifiable->update(['expo_token' => null]);
        } else {
            // do something else like logging...
        }
    }
}
```

The `NotificationFailed::$data` property will contain an instance of `ExpoError` which has the following properties:

```
namespace NotificationChannels\Expo;

final readonly class ExpoError
{
    private function __construct(
        public ExpoErrorType $type,
        public ExpoPushToken $token,
        public string $message,
    ) {}
}
```

Expo Message Request Format
---------------------------

[](#expo-message-request-format)

The `ExpoMessage` class contains the following methods for defining the message payload. All of these methods correspond to the available payload defined in the [Expo Push documentation](https://docs.expo.dev/push-notifications/sending-notifications/#message-request-format).

- [Badge (iOS)](#badge-ios)
- [Body](#body)
- [Category ID](#category-id)
- [Channel ID (Android)](#channel-id-android)
- [JSON data](#json-data)
- [Expiration](#expiration)
- [Mutable content (iOS)](#mutable-content-ios)
- [Notification sound (iOS)](#notification-sound-ios)
- [Priority](#priority)
- [Subtitle (iOS)](#subtitle-ios)
- [Title](#title)
- [TTL (Time to live)](#ttl-time-to-live)

### Badge (iOS)

[](#badge-ios)

Sets the number to display in the badge on the app icon.

```
badge(int $value)
```

Note

The value must be greater than or equal to 0.

### Body

[](#body)

Sets the message body to display in the notification.

```
body(string $value)
text(string $value)
```

Note

The value must not be empty.

### Category ID

[](#category-id)

Sets the ID of the notification category that this notification is associated with.

```
categoryId(string $value)
```

Note

The value must not be empty.

### Channel ID (Android)

[](#channel-id-android)

Sets the ID of the Notification Channel through which to display this notification.

```
channelId(string $value)
```

Note

The value must not be empty.

### JSON data

[](#json-data)

Sets the JSON data for the message.

```
data(Arrayable|Jsonable|JsonSerializable|array $value)
```

Warning

We're compressing JSON payloads that exceed 1 KiB using Gzip (if [`ext-zlib`](https://www.php.net/manual/en/book.zlib.php) is available). While you could technically send more than 4 KiB of data, this is not recommended.

### Expiration

[](#expiration)

Sets the expiration time of the message. Same effect as TTL.

```
expiresAt(DateTimeInterface|int $value)
```

Warning

`TTL` takes precedence if both are set.

Note

The value must be in the future.

### Mutable content (iOS)

[](#mutable-content-ios)

Sets whether the notification can be intercepted by the client app.

```
mutableContent(bool $value = true)
```

### Notification sound (iOS)

[](#notification-sound-ios)

Play the default notification sound when the recipient receives the notification.

```
playSound()
```

Warning

Custom sounds are not supported.

### Priority

[](#priority)

Sets the delivery priority of the message.

```
priority(string $value)
default()
normal()
high()
```

Note

The value must be `default`, `normal` or `high`.

### Subtitle (iOS)

[](#subtitle-ios)

Sets the subtitle to display in the notification below the title.

```
subtitle(string $value)
```

Note

The value must not be empty.

### Title

[](#title)

Set the title to display in the notification.

```
title(string $value)
```

Note

The value must not be empty.

### TTL (Time to live)

[](#ttl-time-to-live)

Set the number of seconds for which the message may be kept around for redelivery.

```
ttl(int $value)
expiresIn(int $value)
```

Warning

Takes precedence over `expiration` if both are set.

Note

The value must be greater than 0.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Muhammed Sari](https://github.com/mabdullahsari)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity52

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 61% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~128 days

Recently: every ~182 days

Total

10

Last Release

62d ago

Major Versions

1.x-dev → v2.0.02024-03-18

PHP version history (4 changes)v1.1.0PHP &gt;=7.4 || ^8.0 || ^8.1 || ^8.2

1.3.1PHP &gt;=7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3

v2.0.0PHP ~8.3

v2.2.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20937037?v=4)[Laravel Notification Channels](/maintainers/laravel-notification-channels)[@laravel-notification-channels](https://github.com/laravel-notification-channels)

---

Top Contributors

[![dwightwatson](https://avatars.githubusercontent.com/u/1100408?v=4)](https://github.com/dwightwatson "dwightwatson (25 commits)")[![nicko170](https://avatars.githubusercontent.com/u/9477420?v=4)](https://github.com/nicko170 "nicko170 (8 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (2 commits)")[![rakoza](https://avatars.githubusercontent.com/u/6500610?v=4)](https://github.com/rakoza "rakoza (2 commits)")[![hramos](https://avatars.githubusercontent.com/u/165856?v=4)](https://github.com/hramos "hramos (1 commits)")[![elodieirdor](https://avatars.githubusercontent.com/u/1608447?v=4)](https://github.com/elodieirdor "elodieirdor (1 commits)")[![andresayej](https://avatars.githubusercontent.com/u/38343686?v=4)](https://github.com/andresayej "andresayej (1 commits)")[![mttlck](https://avatars.githubusercontent.com/u/684897?v=4)](https://github.com/mttlck "mttlck (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/laravel-notification-channels-expo/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-notification-channels-expo/health.svg)](https://phpackages.com/packages/laravel-notification-channels-expo)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
