This package makes it easy to send Ionic Push Notifications with Laravel 5.3.
You can install the package via composer:
composer require laravel-notification-channels/ionic-push-notificationsAdd your Ionic Push Authentication Token to your config/services.php:
// config/services.php
'ionicpush' => [
'key' => env('IONIC_PUSH_API_KEY'),
]Now you can use the channel in your via() method inside the notification:
use NotificationChannels\IonicPushNotifications\IonicPushChannel;
use NotificationChannels\IonicPushNotifications\IonicPushMessage;
use Illuminate\Notifications\Notification;
class FriendRequest extends Notification
{
public function via($notifiable)
{
return [IonicPushChannel::class];
}
public function toIonicPush($notifiable)
{
return IonicPushMessage::create('my-security-profile')
->title('Your title')
->message('Your message')
->sound('ping.aiff')
->payload(['foo' => 'bar');
}
}You can easily set different settings for iOS and Android individually like this...
use NotificationChannels\IonicPushNotifications\IonicPushChannel;
use NotificationChannels\IonicPushNotifications\IonicPushMessage;
use Illuminate\Notifications\Notification;
class FriendRequest extends Notification
{
public function via($notifiable)
{
return [IonicPushChannel::class];
}
public function toIonicPush($notifiable)
{
return IonicPushMessage::create('my-security-profile')
->iosMessage('Your iOS message')
->androidMessage('Your iOS message')
->iosSound('ping.aiff')
->androidSound('ping.aiff');
}
}In order to let your Notification know which device token to send to, add the routeNotificationForIonicPush method to your Notifiable model.
This method needs to return the device token of the user (or the Ionic Auth email address, or Ionic userID of the user).
public function routeNotificationForIonicPush()
{
return $this->device_token;
}create(): Accepts a string value ofyour-security-profile.title(): The title of your notification (for all platforms). Can be overwritten by platform specifictitlemethod (see below).message(): The message content of your notification (for all platforms). Can be overwritten by platform specificmessagemethod (see below).sound(): The title of your notification (for all platforms). Can be overwritten by platform specificsoundmethod (see below).payload(): An array of data to send with your notification. Can be overwritten by platform specificpayloadmethod (see below).scheduled(): Schedule a notification for future delivery. AcceptDateTimeobject or a date as a string.
See here for full details on these methods.
iosMessage()iosTitle()iosBadge()iosPayload()iosSound()iosPriority()iosExpire()iosContentAvailable()
See here for full details on these methods.
androidCollapseKey()androidContentAvailable()androidData()androidDelayWhileIdle()androidIcon()androidIconColor()androidMessage()androidPriority()androidSound()androidTag()androidTimeToLive()androidTitle()
Please see CHANGELOG for more information what has changed recently.
$ composer testIf you discover any security related issues, please email m@rkbee.ch instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.