laravel-notification-channels / onesignal

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

Is it possible to set player id in notification class? #105

Closed vadimwe closed 4 years ago

vadimwe commented 4 years ago

Is it possible to set player id in notification class? Not is model routeNotificationForOneSignal()

I have multiple onesignal apps and I should select one of multiple db fields with tokens

Chris-CWZ commented 4 years ago

not too sure what you're trying to achieve here, are you trying to send notifications to multiple users or send the same notification to the same user with multiple player ids?

vadimwe commented 4 years ago

Sorry, I mean the same user with multiple player ids. I have the same user model and 2 apps with notifications. So I need to decide target app and with it target token to send notification

Chris-CWZ commented 4 years ago

i dont think there's a solution for this. users across different apps should have been separated. the best solution i can think of is to create subclasses under ur User model, e.g. App1User, App2User, and so on. Hence, each model would have its own table to store the data that is specific to that app, for example the player_id. Then you would add the Notifiable trait to those models, and call the routeNotificationForOneSignal() function within the respective models. Using this way, you can send the notification to the correct Model based on your backend logic. Hope this helps!

vadimwe commented 4 years ago

Thx, you are right but I have 2 apps in case my service has each app for each role in service. User can use one of the apps or both as well. I created a little workaround with a helper function that works. Thx for help.

Once again thank you for the great package!

Chris-CWZ commented 4 years ago

may i see the workaround that you implemented? curious to know how it works :D