Trap SMS (Nexmo) notifications when running local dev environment
I'm wondering if anyone has a good pattern or way to do something similar to what Mailtrap or Helo do for emails but for SMS notifications?
I use Nexmo with Laravel notifications and don't want text messages getting send out and ideally I'd like to log them in a way that I can see they are being sent and the content of the messages when working locally.
I'm sure I can figure out a way to do this but wondered if anyone has anything solid they've done to handle this.
This is where I landed... just fired them to Slack if local.
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return app()->isLocal() ? 'slack' : 'nexmo';
}
/**
* Get the Nexmo / SMS representation of the notification.
*
* @param mixed $notifiable
* @return NexmoMessage
*/
public function toNexmo($notifiable)
{
return (new NexmoMessage)->content($this->message);
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)->to('#sms')->content($this->message);
}