AWS SMS Laravel notification
Send sms trough AWS SNS., (*1)
Contents
Installation
You can install the package via composer:, (*2)
``` bash
composer require peec/aws-laravel-notification, (*3)
You must install the service provider:
```php
// config/app.php
'providers' => [
...
NotificationChannels\AWS\AWSSMSServiceProvider::class,
],
Setting up the AWSSMS service
Add to your config/services.php:, (*4)
// config/services.php
...
'awssms' => [
'key' => env('AWSSMS_KEY'),
'secret' => env('AWSSMS_SECRET'),
'region' => env('AWSSMS_REGION'),
'from' => env('AWSSMS_FROM'), // optional
'max_price_usd' => '0.50' // Max price, sms wont send if price of the sms is more then this.
],
...
Usage
Now you can use the channel in your via() method inside the notification:, (*5)
``` php
use NotificationChannels\AWS\AWSSMSChannel;
use NotificationChannels\AWS\AWSSMSMessage;
use Illuminate\Notifications\Notification;, (*6)
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [AWSSMSChannel::class];
}, (*7)
public function toAwsSms($notifiable)
{
return (new AWSSMSMessage())
->content("Your {$notifiable->service} account was approved!");
}
}, (*8)
In order to let your Notification know which phone are you sending/calling to, the channel will look for the `phone_number` attribute of the Notifiable model. If you want to override this behaviour,
add the `routeNotificationForAws` method to your Notifiable model.
```php
public function routeNotificationForAws()
{
return '+1234567890';
}
Available methods
-
from(''): Accepts a phone to use as the notification sender.
-
content(''): Accepts a string value for the notification body.
-
type('Transactional'): Either Transactional or Promotional. See aws docs for SNS SMS. The pricing of these vary.
Changelog
Please see CHANGELOG for more information what has changed recently., (*9)
Testing
bash
$ composer test, (*10)
Security
If you discover any security related issues, please email kjelkenes@gmail.com instead of using the issue tracker., (*11)
Contributing
Please see CONTRIBUTING for details., (*12)
Credits
License
The MIT License (MIT). Please see License File for more information., (*13)