swiftsmsgh-laravel-notification-channels / swiftsmsgh
swiftsms-GH SMS Notification Channel For Laravel
Requires
- php: >=8.1
- illuminate/notifications: ~5.0 || ~6.0 || ~7.0 || ~8.0
- illuminate/support: ~5.0 || ~6.0 || ~7.0 || ~8.0
- swiftsmsgh/swiftsmsgh-api-sdk: ^1.0
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^9.6
README
📲 Swiftsmsgh Notifications Channel for Laravel
Contents
Installation
composer require swiftsmsgh-laravel-notification-channels/swiftsmsgh
Configuration
Add your Swiftsmsgh SENDER_ID and API_TOKEN to your .env
SWIFTSMSGH_API_TOKEN=100|hjwewrahwjew8234wej # always required SWIFTSMSGH_SENDER_ID=Demo # always required
Add the configuration to your services.php
config file:
'swiftsmsgh' => [ 'sender_id' => env('SWIFTSMSGH_SENDER_ID', 'sender_id'), 'api_token' => env('SWIFTSMSGH_API_TOKEN', 'api_token'), ]
Setting up the Swiftsmsgh service
You'll need a Swiftsms-GH account. Head over to their website and create or login to your account.
Navigate to API Integration
and then API Token
in the sidebar to copy existing one or generate an API Token.
Usage
You can use the channel in your via()
method inside the notification:
use Illuminate\Notifications\Notification; use \NotificationChannels\Swiftsmsgh\SwiftsmsghMessage; use \NotificationChannels\Swiftsmsgh\SwiftsmsghChannel; class LoginNeedsVerification extends Notification { public function via($notifiable) { return [SwiftsmsghChannel::class]; } public function Swiftsmsgh($notifiable) { return (new SwiftsmsghMessage) ->content("Task #{$notifiable->id} is complete!") ->from('My App'); } }
In your notifiable model, make sure to include a routeNotificationForSwiftsmsgh()
method, which returns a phone number including country code.
public function routeNotificationForSwiftsmsgh() { return $this->phone; // 0200000001 }
Available methods
sender()
: Sets the sender's name or phone number.
content()
: Set a content of the notification message.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email support@swiftsmsgh.com 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.