You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now you can use the channel in your `via()` method inside the notification:
58
62
59
63
```php
64
+
<?php
65
+
60
66
use NotificationChannels\AwsSns\SnsChannel;
61
67
use NotificationChannels\AwsSns\SnsMessage;
62
68
use Illuminate\Notifications\Notification;
@@ -70,32 +76,24 @@ class AccountApproved extends Notification
70
76
71
77
public function toSns($notifiable)
72
78
{
79
+
// You can just return a plain string:
73
80
return "Your {$notifiable->service} account was approved!";
74
81
75
-
// or
76
-
82
+
// OR explicitly return a SnsMessage object passing the message body:
77
83
return new SnsMessage("Your {$notifiable->service} account was approved!");
78
84
79
-
// or
80
-
81
-
return SnsMessage::create()
82
-
->body("Your {$notifiable->service} account was approved!")
83
-
->transactional()
84
-
->sender("MyStore");
85
-
86
-
// or
87
-
85
+
// OR return a SnsMessage passing the arguments via `create()` or `__construct()`:
88
86
return SnsMessage::create([
89
87
'body' => "Your {$notifiable->service} account was approved!",
90
88
'transactional' => true,
91
-
'sender' => "MyStore"
89
+
'sender' => 'MyBusiness',
92
90
]);
93
91
94
-
// or
95
-
96
-
return SnsMessage::create([
97
-
'body' => "Your {$notifiable->service} account was approved!"
98
-
])->promotional()->sender("MyStore");
92
+
// OR create the object with or without arguments and then use the fluent API:
93
+
return SnsMessage::create()
94
+
->body("Your {$notifiable->service} account was approved!")
95
+
->promotional()
96
+
->sender('MyBusiness');
99
97
}
100
98
}
101
99
```
@@ -106,19 +104,27 @@ Notifiable model. If you want to override this behaviour, add the
106
104
`routeNotificationForSns` method to your Notifiable model.
107
105
108
106
```php
109
-
public function routeNotificationForSns()
110
-
{
111
-
return '+1234567890';
107
+
<?php
108
+
109
+
use Illuminate\Notifications\Notifiable;
110
+
111
+
class SomeModel {
112
+
use Notifiable;
113
+
114
+
public function routeNotificationForSns($notification)
115
+
{
116
+
return '+1234567890';
117
+
}
112
118
}
113
119
```
114
120
115
121
### Available SnsMessage methods
116
122
117
-
-`create([])`: Accepts an array of key-values where the keys corresponds to the methods below and the values are passed as parameters.
118
-
-`body('')`: Accepts a string value for the notification body. Messages with more than 140 characters will be split into multiple messages by SNS without breaking any words.
119
-
-`promotional(bool)`: Sets the SMS attribute as the promotional delivery type (default). Optimizes the delivery for lower costs.
120
-
-`transactional(bool)`: Sets the SMS attribute as the transactional delivery type. Optimizes the delivery to achieve the highest reliability (it also costs more).
121
-
-`sender(string)`: Sets the SMS sender id. It can be up to 11 characters with no spaces.
123
+
-`create([])`: Accepts an array of key-values where the keys corresponds to the methods below and the values are passed as parameters;
124
+
-`body('')`: Accepts a string value for the notification body. Messages with more than 140 characters will be split into multiple messages by SNS without breaking any words;
125
+
-`promotional(bool)`: Sets the delivery type as promotional (default). Optimizes the delivery for lower costs;
126
+
-`transactional(bool)`: Sets the delivery type as transactional. Optimizes the delivery to achieve the highest reliability (it also costs more);
127
+
-`sender(string)`: Up to 11 characters with no spaces, that is displayed as the sender on the receiving device. [Support varies by country](https://docs.aws.amazon.com/sns/latest/dg/sns-supported-regions-countries.html).
122
128
123
129
More information about the SMS Attributes can be found on the [AWS SNS Docs](https://docs.aws.amazon.com/pt_br/sdk-for-php/v3/developer-guide/sns-examples-sending-sms.html#get-sms-attributes).
124
130
It's important to know that the attributes set on the message will override the
0 commit comments