This package makes it easy to send notifications using AwsPinpoint with Laravel 5.5+ and 6.0.
Note: Currently only SMS is supported. Other message types like voice and email are on the roadmap. Please get in touch if you would like to help out with this.
Send SMS using AWS Pinpoint the easy way.
You can install the package via composer by running the command below
composer require kielabokkie/aws-pinpoint-laravel-notification-channel
This package uses the AWS Service Provider for Laravel package. You'll need to add specific configuration for AWS Pinpoint to your config/aws.php
file. See the example below:
...
'Pinpoint' => [
'region' => env('AWS_PINPOINT_REGION'),
'application_id' => env('AWS_PINPOINT_APPLICATION_ID'),
'sender_id' => env('AWS_PINPOINT_SENDER_ID'),
'key' => env('AWS_PINPOINT_KEY'),
'secret' => env('AWS_PINPOINT_SECRET'),
],
...
And then add the following entries in your .env
file:
...
AWS_PINPOINT_REGION=
AWS_PINPOINT_APPLICATION_ID=
AWS_PINPOINT_SENDER_ID=
AWS_PINPOINT_KEY=
AWS_PINPOINT_SECRET=
...
Once everything is setup you can send a notification as follows:
<?php
namespace App\Notifications;
use App\User;
use Illuminate\Notifications\Notification;
use NotificationChannels\AwsPinpoint\AwsPinpointChannel;
use NotificationChannels\AwsPinpoint\AwsPinpointSmsMessage;
class PhoneVerificationCreated extends Notification
{
/**
* Get the notification's delivery channels.
*
* @param \App\User $notifiable
* @return array
*/
public function via(User $notifiable)
{
return [AwsPinpointChannel::class];
}
/**
* Send SMS via AWS Pinpoint.
*
* @param \App\User $notifiable
* @return \NotificationChannels\AwsPinpoint\AwsPinpointSmsMessage
*/
public function toAwsPinpoint(User $notifiable)
{
$message = sprintf('Your order %s has been dispatched', $this->orderId);
return (new AwsPinpointSmsMessage($message))
->setRecipients($notifiable->mobile_number);
}
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.