Download the PHP package laravel-notification-channels/expo without Composer

On this page you can find all versions of the php package laravel-notification-channels/expo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package expo

Social Card of Laravel Expo Channel

Expo Notifications Channel

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Expo channel for pushing notifications to your React Native apps.

Contents

Installation

You can install the package via Composer:

Additional Security (optional)

You can require any push notifications to be sent with an additional Access Token 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:

Usage

You can now use the expo channel in the via() method of your Notifications.

Notification / ExpoMessage

First things first, you need to have a Notification that needs to be delivered to someone. Check out the Laravel documentation for more information on generating notifications.

[!NOTE] Detailed explanation regarding the Expo Message Request Format can be found here.

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

Notifiable / ExpoPushToken

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

Unicasting (single device)

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

[!IMPORTANT] No notifications will be sent in case of null.

[!NOTE] More info regarding the model cast can be found here.

Multicasting (multiple devices)

The method must return an array<int, ExpoPushToken> or Collection<int, ExpoPushToken>, the specific implementation depends on your use case. An example:

[!IMPORTANT] No notifications will be sent in case of an empty Collection.

Sending

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

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:

Model casting

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

This custom value object guarantees the integrity of the push token. You should make sure that only valid tokens are saved.

Handling failed deliveries

Unfortunately, Laravel does not provide an OOB solution 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:

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

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.

Badge (iOS)

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

[!NOTE] The value must be greater than or equal to 0.

Body

Sets the message body to display in the notification.

[!NOTE] The value must not be empty.

Category ID

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

[!NOTE] The value must not be empty.

Channel ID (Android)

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

[!NOTE] The value must not be empty.

JSON data

Sets the JSON data for the message.

[!WARNING] We're compressing JSON payloads that exceed 1 KiB using Gzip (if ext-zlib is available). While you could technically send more than 4 KiB of data, this is not recommended.

Expiration

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

[!WARNING] TTL takes precedence if both are set.

[!NOTE] The value must be in the future.

Mutable content (iOS)

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

Notification sound (iOS)

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

[!WARNING] Custom sounds are not supported.

Priority

Sets the delivery priority of the message.

[!NOTE] The value must be default, normal or high.

Subtitle (iOS)

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

[!NOTE] The value must not be empty.

Title

Set the title to display in the notification.

[!NOTE] The value must not be empty.

TTL (Time to live)

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

[!WARNING] Takes precedence over expiration if both are set.

[!NOTE] The value must be greater than 0.

Testing

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

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


All versions of expo with dependencies

PHP Build Version
Package Version
Requires php Version ~8.3
ext-json Version *
guzzlehttp/guzzle Version ^7.1
illuminate/contracts Version ^11.0
illuminate/notifications Version ^11.0
illuminate/support Version ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laravel-notification-channels/expo contains the following files

Loading the files please wait ....