skip to Main Content

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 AppNotifications;

 use IlluminateBusQueueable;
 use IlluminateContractsQueueShouldQueue;
 use IlluminateNotificationsMessagesMailMessage;
 use IlluminateNotificationsNotification;
 use IlluminateNotificationsMessagesVonageMessage;

 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 IlluminateNotificationsMessagesMailMessage
 */
// 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."

3

Answers


  1. 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 configapp.php

    Add this line:

    use IlluminateNotificationsVonageChannelServiceProvider;

    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 IlluminateNotificationsVonageChannelServiceProvider;
    
    return [
         .......
         .......
         .......
         .......
        'providers' => [
         .......
         .......
         .......
         .......
            AppProvidersEventServiceProvider::class,
            AppProvidersRouteServiceProvider::class,
            AppProvidersViewServiceProvider::class,
            VonageChannelServiceProvider::class,
        ],
         .......
         .......
         .......
         .......
    ];
    

    Hope this will help you.

    Login or Signup to reply.
  2. Just need to publish provider it will work for me

    php artisan vendor:publish --provider="VonageLaravelVonageServiceProvider"
    
    Login or Signup to reply.
  3. It seems like you are trying to use the Vonage driver for SMS notifications in your Laravel application, but you are getting an error saying that the driver is not supported.

    Based on your code, it looks like you have correctly set up the notification class and defined the Vonage driver as a delivery channel. However, you need to make sure that you have also properly installed the Vonage package and added the necessary configuration settings to your Laravel application.

    Here are some steps you can take to troubleshoot the issue:

    Make sure that you have installed the Vonage package by running the following command in your terminal:

    bash

    composer require nexmo/client
    Add your Vonage API credentials to your Laravel application’s .env file:

    makefile

    NEXMO_KEY=your_key_here
    NEXMO_SECRET=your_secret_here
    NEXMO_FROM=your_vonage_phone_number_here
    In your Laravel application’s config/services.php file, add the following configuration for the Vonage driver:

    bash

    ‘vonage’ => [
    ‘key’ => env(‘NEXMO_KEY’),
    ‘secret’ => env(‘NEXMO_SECRET’),
    ‘from’ => env(‘NEXMO_FROM’),
    ],
    Make sure that you have imported the VonageMessage class at the top of your notification class:

    mathematica

    use Illuminate\Notifications\Messages\VonageMessage;
    Finally, clear your Laravel application’s cache by running the following command in your terminal:

    arduino

    php artisan cache:clear
    After following these steps, try running your code again and see if you still get the “Driver [vonage] not supported” error. If you are still having issues, you may want to double-check your configuration settings or consult the Vonage documentation for further troubleshooting steps.

    SMSala Bulk SMS Service Provider

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search