PHP code example of gvital3230 / laravel-notification-channel-viber-net-ua

1. Go to this page and download the library: Download gvital3230/laravel-notification-channel-viber-net-ua library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gvital3230 / laravel-notification-channel-viber-net-ua example snippets


// config/services.php
...
    'vibernetua' => [
        'endpoint' => env('VIBERNETUA_ENDPOINT', 'https://my2.viber.net.ua/api/v2/viber/dispatch'),
        'token' => env('VIBERNETUA_TOKEN'),
        'sender' => env('VIBERNETUA_SENDER'),
        'debug' => env('VIBERNETUA_DEBUG'),
        'sandboxMode' => env('VIBERNETUA_SANDBOX_MODE', false),
    ],
...

use Illuminate\Notifications\Notification;
use NotificationChannels\ViberNetUa\ViberNetUaMessage;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return ['vibernetua'];
    }

    public function toViberNetUa($notifiable)
    {
        return (new ViberNetUaMessage(
            \NotificationChannels\ViberNetUa\ViberNetUaMessageType::TYPE_ONLY_MESSAGE(), 
            'Account approved', 
            'Congratulations, your accaunt was approved!'));       
    }
}

public function routeNotificationForViberNetUa()
{
    return $this->phone;
}

Notification::route('vibernetua', '+380501111111')                      
            ->notify(new AccountApproved());