Skip to content

quincykwende/aws-pinpoint-laravel-notification-channel

 
 

Repository files navigation

AWS Pinpoint Laravel Notification Channel

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using AwsPinpoint with Laravel 5.5+, 6.0, 7.0, 8.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.

Contents

Installation

You can install the package via composer by running the command below

composer require kielabokkie/aws-pinpoint-laravel-notification-channel

Setting up the AwsPinpoint service

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=
...

Usage

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)->setSenderId($notifiable->senderId);
    }
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

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

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

About

Send SMS using AWS Pinpoint the easy way

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%