kingscode / laravel-apns-notification-channel
Apple push notification service (Laravel notification channel).
Installs: 4 129
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.2
- edamov/pushok: ^0.6.4
- illuminate/notifications: ^6.0|^7.0
- illuminate/support: ^6.0|^7.0
README
⚠️ Abandoned ⚠️
This package was written at a time where the offical Laravel Notification Channels didn't support the "new" APNs API.
This package is hereby no longer maintained and you should seriously consider upgrading to laravel-notification-channels/apn
Laravel APNS Notification Channel
Apple push notification service (Laravel notification channel).
Installation
Require the package.
composer require kingscode/laravel-apns-notification-channel
You will need to get a p8
certificate for you application from apple
, before you can use this channel. Configure the path in config/broadcasting.php
.
'connections' => [ 'apn' => [ 'key_id' => env('APN_KEY_ID'), 'team_id' => env('APN_TEAM_ID'), 'app_bundle' => env('APN_APP_BUNDLE'), 'private_key' => storage_path('apn.p8'), 'private_key_password' => env('APN_KEY_PASSWORD', null), 'is_production' => env('APN_PRODUCTION', false), ], ];
Usage
In your notifiable
model, make sure to include a routeNotificationForApn()
method which may return a single token or an array of tokens.
public function routeNotificationForApn(): string { return $this->apn_token; }
And in your Notification
add a toApn
method that returns a Message
.
/** * Get the notification in APN format. * * @param $notifiable * @return \KingsCode\LaravelApnsNotificationChannel\Message */ public function toApn($notifiable): Message { return (new Message()) ->setTitle('title') ->setBody('body'); }
And make sure your via
method returns the ApnChannel
.
public function via($notifiable): array { return [ApnChannel::class]; }