diff --git a/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php b/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php index 41c1fc6b7224..619332425535 100644 --- a/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php +++ b/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php @@ -55,7 +55,7 @@ public function send($notifiable, Notification $notification) } return $this->nexmo->message()->send([ - 'type' => 'unicode', + 'type' => $message->type, 'from' => $message->from ?: $this->from, 'to' => $to, 'text' => trim($message->content), diff --git a/src/Illuminate/Notifications/Messages/NexmoMessage.php b/src/Illuminate/Notifications/Messages/NexmoMessage.php index 16f7504977a8..293cf032e6d6 100644 --- a/src/Illuminate/Notifications/Messages/NexmoMessage.php +++ b/src/Illuminate/Notifications/Messages/NexmoMessage.php @@ -18,6 +18,13 @@ class NexmoMessage */ public $from; + /** + * The message type. + * + * @var string + */ + public $type = 'text'; + /** * Create a new message instance. * @@ -54,4 +61,16 @@ public function from($from) return $this; } + + /** + * Set the message type. + * + * @return $this + */ + public function unicode() + { + $this->type = 'unicode'; + + return $this; + } } diff --git a/tests/Notifications/NotificationNexmoChannelTest.php b/tests/Notifications/NotificationNexmoChannelTest.php index abbe80692979..2f699ec56819 100644 --- a/tests/Notifications/NotificationNexmoChannelTest.php +++ b/tests/Notifications/NotificationNexmoChannelTest.php @@ -20,6 +20,7 @@ public function testSmsIsSentViaNexmo() ); $nexmo->shouldReceive('message->send')->with([ + 'type' => 'text', 'from' => '4444444444', 'to' => '5555555555', 'text' => 'this is my message', @@ -38,6 +39,7 @@ public function testSmsIsSentViaNexmoWithCustomFrom() ); $nexmo->shouldReceive('message->send')->with([ + 'type' => 'unicode', 'from' => '5554443333', 'to' => '5555555555', 'text' => 'this is my message', @@ -65,6 +67,6 @@ class NotificationNexmoChannelTestCustomFromNotification extends Notification { public function toNexmo($notifiable) { - return (new NexmoMessage('this is my message'))->from('5554443333'); + return (new NexmoMessage('this is my message'))->from('5554443333')->unicode(); } }