Unisender Notifications Channel For Laravel 5.5+
![StyleCI][ico-styleci]
![Software License][ico-license], (*1)
Requirements
This package requires PHP 7.1 or higher., (*2)
Installation
You can install the package via composer:, (*3)
``` bash
$ composer require tzurbaev/unisender-notifications-channel, (*4)
### Setting up the Unisender Service
Add Unisender API key to the `config/services.php` file:
```php
'unisender' => [
'api-key' => 'KEY_HERE',
],
This key will be used as default key for all notifications. You can always override it for concrete notifications., (*5)
Documentation
Add UnisenderChannell::class to notification's via method and implement toUnisender($notifiable) method:, (*6)
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NotificationChannels\Unisender\UnisenderChannel;
use NotificationChannels\Unisender\UnisenderMessage;
class SubscriptionActivatedNotification extends Notification
{
public function via($notifiable)
{
return [UnisenderChannel::class];
}
public function toUnisender($notifiable)
{
return (new UnisenderMessage)
->from('Laravel')
->content('Your subscription is active!');
}
}
Also, your Notifiable classes must have the routeNotificationForUnisender method, which should return single phone number (E.164 format) or list of phone numbers (comma-separated or in array)., (*7)
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForUnisender()
{
return '+79641234567'; // or ['+79641234567', '+79831234567'];
}
}
Available Methods
-
UnisenderMessage::silent(bool $flag = true) - sets the 'silent mode' - Channel won't throw any exception while sending SMS;
-
UnisenderMessage::usingAccessToken($token) - reset token only for the current message;
-
UnisenderMessage::from(string $from) - set the sender name;
-
UnisenderMessage::content(string $content) - set the message content.
Change log
Please see CHANGELOG for more information on what has changed recently., (*8)
Testing
bash
$ vendor/bin/phpunit, (*9)
Contributing
Please see CONTRIBUTING for details., (*10)
Security
If you discover any security related issues, please email zurbaev@gmail.com instead of using the issue tracker., (*11)
License
The MIT License (MIT). Please see License File for more information., (*12)