LaravelPackages.net
Acme Inc.
Toggle sidebar
apantle/laravel-notification-apn-http2

Dependency free Apple Push Notifications provider, configurable for multiple apps

614
0
0.1.3
About apantle/laravel-notification-apn-http2

apantle/laravel-notification-apn-http2 is a Laravel package for dependency free apple push notifications provider, configurable for multiple apps. It currently has 0 GitHub stars and 614 downloads on Packagist (latest version 0.1.3). Install it with composer require apantle/laravel-notification-apn-http2. Discover more Laravel packages by apantle or browse all Laravel packages to compare alternatives.

Last updated

Dependency free Apple Push Notifications for Laravel

Latest Version on Packagist Maintainability Build Status Total Downloads Test Coverage

This package doesn't require 3rd party dependencies, and it allows sending of pushes to multiple apps, using differente PEM certificates and Apple Bundle Ids.

Installation

You can install the package via composer:

composer require apantle/laravel-notification-apn-http2

Usage

Store your certificates in directory certificates (sibling to directory app)

Implement toApn method in your notification class:

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)
    ;
}

Implement method routeNotificationForApn() in your notifiable models, returning a single device token or an array of tokens:

public function routeNotificationForApn($notification)
{
    return empty($notification->tokens)
        ? $this->devices->pluck('token')
        : $notification->tokens;
}

Configuration

APN_HTTP2_PRODUCTION=true APN_HTTP2_TOPIC=work.jefrancomix.demo APN_HTTP2_CERTIFICATE=demo.pem APN_HTTP2_CERT_PASSWORD=Aw3$om3!

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Star History Chart