This package makes it easy to send Utalk messages using the Laravel notification system. Supports 5.5+, 6.x, 7.x and 8.x.
You can install the package via composer:
composer require powertic/utalk-notification-channel
Add your Utalk token on app/services.php
file. You can get your API Token here.
...
'utalk' => [
'token' => env('UTALK_TOKEN'),
],
You need to create a UTALK_TOKEN
on your .env
file.
Now you can use the channel in your via()
method inside the notification:
use Powertic\Utalk\UtalkChannel;
use Powertic\Utalk\UtalkMessage;
use Illuminate\Notifications\Notification;
class TeamCreated extends Notification
{
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [UtalkChannel::class];
}
/**
* Get the UTalk representation of the notification.
*
* @param mixed $notifiable
* @return \Powertic\Utalk\UtalkMessage
*/
public function toUtalk($notifiable)
{
return UtalkMessage::create()
->message("Hello World!");
}
}
In order to let your Notification know which number should receive the message, add the routeNotificationForUtalk
method to your Notifiable model.
This method expects a valid E.164 mobile number where the notification will be sent.
/**
* Route notifications for the Utalk channel.
*
* @return string
*/
public function routeNotificationForUtalk()
{
return $this->mobile;
}
message('Hello World!')
: Accepts a string as message to send.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.