Skip to content

wapacro/swisscom-sms-channel

Repository files navigation

Swisscom SMS Notification Channel

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

This package makes it easy to send notifications using Swisscom's SMS API with Laravel 5.5+, 6.x and 7.x

Note: Replace :style_ci_id :sensio_labs_id with their correct values

Contents

Installation

Install the package using composer:

composer require laravel-notification-channels/swisscom

Add the configuration to your services.php config file:

'swisscom' => [
    'key' => env('SWISSCOM_KEY'),
    'from' => env('SWISSCOM_FROM'),
]

Setting up the Swisscom SMS service

To get the necessary key you'll need to sign-up for an SMS plan using Swisscom's Digital Marketplace. After signing up head over to your subscriptions and extract the "customer key" under "Applications".

Depending on your selected plan you have the option to use custom sender names (from config). The fallback sender value and default for entry plans is your within Swisscom registered mobile phone number.

Usage

Within your notification you need to add the Swisscom SMS channel to your via() method and configure the message using the toSwisscom() method:

use Illuminate\Notifications\Notification;
use NotificationChannels\Swisscom\SwisscomChannel;
use NotificationChannels\Swisscom\SwisscomMessage;

class SignedUp extends Notification
{
    public function via($notifiable)
    {
        return [SwisscomChannel::class];
    }

    public function toSwisscom($notifiable)
    {
        // Easiest way
        return 'My awesome SMS message';
    
        // Classic way
        return new SwisscomMessage('My awesome SMS message');
        
        // Advanced options
        return (new SwisscomMessage)
            ->text('My awesome SMS message')
            ->from('Acme Ltd.')
            ->to('+41791234567')
            ->callback('https://my-app.com/delivery-callback')
    }
}

Note on advanced options:

  • If you don't provide a sender name/number using from() then the config option services.swisscom.from will be used
  • If you don't provide a receiver number using to() in your notification please add a routeNotificationForSwisscom() method to your notifiable model

Available Message methods

text(): Sets the message content of the SMS

from(): Sets the SMS sender name/number (overwrites the configured sender in services.php)

to(): Sets the SMS receiver number (overwrites return value of routeNotificationForSwisscom() in notifiable model)

callback(): Sets the callback URL for delivery notifications according to Swisscom's API spec

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please notify the maintainer 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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages