-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send Notification based on the E-Mail instead of the OneSignal User ID #40
Merged
Lloople
merged 8 commits into
laravel-notification-channels:master
from
LKaemmerling:implement-email-targeting
Jan 5, 2018
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7949069
Start Implementing
LKaemmerling ddd21fc
Switch from field tags to field filters
LKaemmerling 64d797d
Index "key" was wrong should be "field"
LKaemmerling 50921f2
filters need an array as parameter
LKaemmerling da19342
Implement Support for multiple E-Mail Adresses
LKaemmerling 25ab84f
Remove all parts for sending to multiple E-Mails.
LKaemmerling ba013ab
Rename NotifiableEMail to NotifiableEmail
Lloople 1a6a178
Following code style convention
Lloople File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,15 @@ public function routeNotificationForOneSignal() | |
} | ||
``` | ||
|
||
If you want to send the notification based on the OneSignal "syncHashedEmail" feature just return an array with the index "email". **It isn't possible to use multiple E-Mails on one filter because of a limitation of the OneSignal API.** | ||
|
||
```php | ||
public function routeNotificationForOneSignal() | ||
{ | ||
return ['email' => '[email protected]']; | ||
} | ||
``` | ||
|
||
### All available methods | ||
|
||
- `subject('')`: Accepts a string value for the title. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
class ChannelTest extends TestCase | ||
{ | ||
|
||
/** @var Mockery\Mock */ | ||
protected $oneSignal; | ||
|
||
|
@@ -80,4 +81,31 @@ public function it_throws_an_exception_when_it_could_not_send_the_notification() | |
|
||
$this->channel->send(new Notifiable(), new TestNotification()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_can_send_a_notification_with_email() | ||
{ | ||
$response = new Response(200); | ||
|
||
$this->oneSignal->shouldReceive('sendNotificationCustom') | ||
->once() | ||
->with([ | ||
'contents' => ['en' => 'Body'], | ||
'headings' => ['en' => 'Subject'], | ||
'url' => 'URL', | ||
'buttons' => [], | ||
'web_buttons' => [], | ||
'chrome_web_icon' => 'Icon', | ||
'chrome_icon' => 'Icon', | ||
'adm_small_icon' => 'Icon', | ||
'small_icon' => 'Icon', | ||
'filters' => collect([["field" => "email", "value" => '[email protected]']]), | ||
]) | ||
->andReturn($response); | ||
|
||
$this->channel->send(new NotifiableEMail(), new TestNotification()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace NotificationChannels\OneSignal\Test; | ||
|
||
class NotifiableEMail | ||
{ | ||
|
||
use \Illuminate\Notifications\Notifiable; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function routeNotificationForOneSignal() | ||
{ | ||
return ['email' => '[email protected]']; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this class be named
NotifiableEmail
instead ofNotifiableEMai
? 🤔