swiftsms-GH SMS Notification Channel For Laravel

v1.0.1 2024-01-19 19:32 UTC

This package is auto-updated.

Last update: 2024-04-19 20:34:59 UTC


README

Latest Version on Packagist Software License Build Status StyleCI Total Downloads

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