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
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'),
]
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.
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 optionservices.swisscom.from
will be used - If you don't provide a receiver number using
to()
in your notification please add arouteNotificationForSwisscom()
method to your notifiable model
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
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please notify the maintainer instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.