Skip to content

Commit cebf5a1

Browse files
committed
README updated
1 parent 91a5df2 commit cebf5a1

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

README.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,29 @@ composer require laravel-notification-channels/aws-sns
4040
Add your AWS key ID, secret and default region to your `config/services.php`:
4141

4242
```php
43-
// config/services.php
44-
45-
// ...
46-
'sns' => [
47-
'key' => env('AWS_ACCESS_KEY_ID'),
48-
'secret' => env('AWS_SECRET_ACCESS_KEY'),
49-
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
50-
'version' => 'latest',
51-
],
52-
// ...
43+
<?php
44+
45+
return [
46+
47+
// ...
48+
49+
'sns' => [
50+
'key' => env('AWS_ACCESS_KEY_ID'),
51+
'secret' => env('AWS_SECRET_ACCESS_KEY'),
52+
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
53+
'version' => 'latest',
54+
],
55+
56+
];
5357
```
5458

5559
## Usage
5660

5761
Now you can use the channel in your `via()` method inside the notification:
5862

5963
```php
64+
<?php
65+
6066
use NotificationChannels\AwsSns\SnsChannel;
6167
use NotificationChannels\AwsSns\SnsMessage;
6268
use Illuminate\Notifications\Notification;
@@ -70,32 +76,24 @@ class AccountApproved extends Notification
7076

7177
public function toSns($notifiable)
7278
{
79+
// You can just return a plain string:
7380
return "Your {$notifiable->service} account was approved!";
7481

75-
// or
76-
82+
// OR explicitly return a SnsMessage object passing the message body:
7783
return new SnsMessage("Your {$notifiable->service} account was approved!");
7884

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()`:
8886
return SnsMessage::create([
8987
'body' => "Your {$notifiable->service} account was approved!",
9088
'transactional' => true,
91-
'sender' => "MyStore"
89+
'sender' => 'MyBusiness',
9290
]);
9391

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');
9997
}
10098
}
10199
```
@@ -106,19 +104,27 @@ Notifiable model. If you want to override this behaviour, add the
106104
`routeNotificationForSns` method to your Notifiable model.
107105

108106
```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+
}
112118
}
113119
```
114120

115121
### Available SnsMessage methods
116122

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).
122128

123129
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).
124130
It's important to know that the attributes set on the message will override the

0 commit comments

Comments
 (0)