Closed Zubair-Iftikhar closed 2 years ago
I believe you are using the wrong way. The Usage section addresses this.
You have to put the routeNotificationForSns()
in the model you are trying to send the notification to. If its a User, get the phone number of the user, not the mobile number of the notification. There is no property mobileNumber
in the notification object.
I think it should be:
<?php
use Illuminate\Notifications\Notifiable;
class SomeModel {
use Notifiable;
public function routeNotificationForSns($notification)
{
return $this->mobileNumber;
}
}
I believe you are using the wrong way. The Usage section addresses this.
You have to put the
routeNotificationForSns()
in the model you are trying to send the notification to. If its a User, get the phone number of the user, not the mobile number of the notification. There is no propertymobileNumber
in the notification object.I think it should be:
<?php use Illuminate\Notifications\Notifiable; class SomeModel { use Notifiable; public function routeNotificationForSns($notification) { return $this->mobileNumber; } }
already do in User model.. but not working
Yes, its in the user model, but the code you posted is wrong. It's not return $notification->mobileNumber;
, it should be return $this->mobileNumber;
If you already fixed this, and is not working yet, this issue here can help you debug what's happening: https://github.com/laravel-notification-channels/aws-sns/issues/9
routeNotificationForSns is not working.. in User Model.. if then db field is phone then it's working fine.. but what if field name other?