嗨,我正在使用Nexmo API制作laravel短信通知。
我已经按照给定的laravel文档以及github中的说明集成了nexmo。
我的下面的代码运行良好。
Nexmo::message()->send([
'to' => 'xxxxxxx',
'from' => 'xxxxxxx',
'text' => 'Using the facade to send a message.'
]);上面的代码是发送短信。
我需要将此作为通知进行集成。但不幸的是,return ['nexmo']不起作用。它没有命中通知中的toNexmo($notifiable)方法。
有人能帮我吗。
谢谢
发布于 2018-02-21 01:07:12
有两种方式可以通过Nexmo发送通知-使用内置的通知包和使用Nexmo客户端。您已经使用客户端实现了它,但是看起来您希望使用通知包,以便它调用toNexmo。
要通过Laravel发送通知,请按如下方式发送:
Notification::send($yourUser, new SomethingNotification());
SomethingNotification定义如下所示:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\NexmoMessage;
class SomethingNotification extends Notification
{
public function via($notifiable)
{
return ['nexmo'];
}
public function toNexmo($notifiable)
{
return (new NexmoMessage)
->content('Some content');
}
}发布于 2020-05-06 12:38:17
您需要在用户型号上指定To电话号码:
public function routeNotificationForNexmo($notification)
{
return $this->phone_number;
}https://stackoverflow.com/questions/48887036
复制相似问题