laravel-notification-channels / onesignal

OneSignal notifications channel for Laravel
MIT License
283 stars 119 forks source link

Send Notification based on the E-Mail instead of the OneSignal User ID #40

Closed LKaemmerling closed 6 years ago

LKaemmerling commented 6 years ago

As wished from many parts and needed by myself, hear it comes.

After this PR it is possible to send a Notification Based on the User E-Mail.(https://documentation.onesignal.com/docs/email-syncing-and-targeting)

To use this feature, you must sync the E-Mail first with OneSignal and than change the Method "routeNotificationForOneSignal()" on your notifiable Model to something like this:

public function routeNotificationForOneSignal()
{
      return ['email' => 'test@example.com'];
}

Because of the new index 'email' the package knows that it should use the email filter instead of the OneSignalUserId.

Actually it isn't possible to use an array with multiple E-Mails, because of a limitation from the OneSignal Api.

This PR keeps the BC and doesn't require a change to existing installations of the package.

LKaemmerling commented 6 years ago

Travis fails because of an error from packagist, looks like they had a temporary issue. (because the test fails on only one php version)