2

I am trying to make use of Vonage for sms capabilities of the app im building. I installed vonage for it. But using it gives me Error 'driver vonage is not supported'

  <?php

 namespace App\Notifications;

 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Notifications\Messages\MailMessage;
 use Illuminate\Notifications\Notification;
 use Illuminate\Notifications\Messages\VonageMessage;

 class ShortListNotif extends Notification
{
 use Queueable;

/**
 * Create a new notification instance.
 *
 * @return void
 */
public function __construct()
{
    //
}

/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return ['vonage'];
    // return $notifiable->prefers_sms ? ['vonage'] : ['mail', 'database'];
}

/**
 * Get the mail representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return \Illuminate\Notifications\Messages\MailMessage
 */
// public function toMail($notifiable)
// {
//     return (new MailMessage)
//                 ->line('The introduction to the notification.')
//                 ->action('Notification Action', url('/'))
//                 ->line('Thank you for using our application!');
// }

public function routeNotificationForVonage($notification)
{
    return $this->phone_number;
}

public function toVonage($notifiable)
{
    return (new VonageMessage())
        ->clientReference((string) $notifiable->id)
        ->content('Congrats!');
}

/**
 * Get the array representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function toArray($notifiable)
{
    return [
        //
    ];
}

}

here is my Notification Class

and this is what im using to call it, im using on-demand since it does not come from my User.

  Notification::route('vonage', '111111111')->notify(new ShortListNotif());

but i get this error "InvalidArgumentException: Driver [vonage] not supported."

2 Answers2

1

Just need to publish provider it will work for me

php artisan vendor:publish --provider="Vonage\Laravel\VonageServiceProvider"
yagnik devani
  • 97
  • 1
  • 7
0

I faced the same issue, and I resolved it by adding the Vonage service provider to my app config providers items, like this below:

In the config\app.php

Add this line:

use Illuminate\Notifications\VonageChannelServiceProvider;

At the top of the file

and add this to the 'providers' array:

VonageChannelServiceProvider::class

Your config app.php file should be something like this:

<?php

use Illuminate\Notifications\VonageChannelServiceProvider;

return [
     .......
     .......
     .......
     .......
    'providers' => [
     .......
     .......
     .......
     .......
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        App\Providers\ViewServiceProvider::class,
        VonageChannelServiceProvider::class,
    ],
     .......
     .......
     .......
     .......
];

Hope this will help you.