@@ -36,46 +36,90 @@ You must install the service provider:
36
36
// config/app.php
37
37
'providers' => [
38
38
...
39
- NotificationChannels\TwilioNotifications\Provider ::class,
39
+ NotificationChannels\Twilio\TwilioProvider ::class,
40
40
];
41
41
```
42
42
43
+ ### Setting up your Twilio account
44
+
45
+ Add your Twilio Account SID, Auth Token, and From Number (optional) to your ` config/services.php ` :
46
+
47
+ ``` php
48
+ // config/services.php
49
+
50
+ 'twilio' => [
51
+ 'account_sid' => env('TWILIO_ACCOUNT_SID'),
52
+ 'auth_token' => env('TWILIO_AUTH_TOKEN'),
53
+ 'from' => env('TWILIO_FROM'), // optional
54
+ ]
55
+ ```
56
+
43
57
## Usage
44
58
45
59
Now you can use the channel in your ` via() ` method inside the notification:
46
60
47
61
``` php
48
- use NotificationChannels\TwilioNotifications\Channel ;
49
- use NotificationChannels\TwilioNotifications\SmsMessage ;
62
+ use NotificationChannels\Twilio\TwilioChannel ;
63
+ use NotificationChannels\Twilio\TwilioSmsMessage ;
50
64
use Illuminate\Notifications\Notification;
51
65
52
66
class AccountApproved extends Notification
53
67
{
54
68
public function via($notifiable)
55
69
{
56
- return [Channel ::class];
70
+ return [TwilioChannel ::class];
57
71
}
58
72
59
73
public function toTwilio($notifiable)
60
74
{
61
- return (new SmsMessage ())
75
+ return (new TwilioSmsMessage ())
62
76
->content("Your {$notifiable->service} account was approved!");
63
77
}
64
78
}
65
79
```
66
80
67
- ### Setting up your Twilio account
81
+ You can also create a Twilio call:
68
82
69
- TODO
83
+ ``` php
84
+ use NotificationChannels\Twilio\TwilioChannel;
85
+ use NotificationChannels\Twilio\TwilioCallMessage;
86
+ use Illuminate\Notifications\Notification;
70
87
71
- ## Usage
88
+ class AccountApproved extends Notification
89
+ {
90
+ public function via($notifiable)
91
+ {
92
+ return [TwilioChannel::class];
93
+ }
72
94
73
- TODO
95
+ public function toTwilio($notifiable)
96
+ {
97
+ return (new TwilioCallMessage())
98
+ ->url("http://example.com/your-twiml-url");
99
+ }
100
+ }
101
+ ```
102
+
103
+ In order to let your Notification know which phone are you sending/calling to, add the ` routeNotificationForTwilio ` method to your Notifiable model.
104
+
105
+ ``` php
106
+ public function routeNotificationForTwitter()
107
+ {
108
+ return '+1234567890';
109
+ }
110
+ ```
74
111
75
112
### Available Message methods
76
113
77
- TODO
114
+ #### TwilioSmsMessage
78
115
116
+ - ` from('') ` : Accepts a phone to use as the notification sender.
117
+ - ` content('') ` : Accepts a string value for the notification body.
118
+
119
+ #### TwilioCallMessage
120
+
121
+ - ` from('') ` : Accepts a phone to use as the notification sender.
122
+ - ` url('') ` : Accepts an url for the call TwiML.
79
123
80
124
## Changelog
81
125
@@ -87,13 +131,13 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen
87
131
$ composer test
88
132
```
89
133
90
- ## Contributing
134
+ ## Security
91
135
92
- Please see [ CONTRIBUTING ] ( CONTRIBUTING.md ) for details .
136
+ If you discover any security related issues, please email [email protected] instead of using the issue tracker .
93
137
94
- ## Security
138
+ ## Contributing
95
139
96
- If you discover any security related issues, please email [email protected] instead of using the issue tracker .
140
+ Please see [ CONTRIBUTING ] ( CONTRIBUTING.md ) for details .
97
141
98
142
## Credits
99
143
0 commit comments