laravel-notification-channels / onesignal

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

Add iOS badge helpers #55

Closed timacdonald closed 6 years ago

timacdonald commented 6 years ago

Added a few helper methods to help deal with badge counts on iOS. Note that these only apply to iOS - as OneSignal does not allow badge counts on Android.

From the docs:

Badges - shows the number of notifications outstanding. Note: Android badges are automatically handled by OneSignal.

// source: https://documentation.onesignal.com/reference#section-appearance

I doubt you want to add methods for every parameter, but I thought this was a good candidate because it's not just key / value, but a couple of key / values to get it working. Tripped me up for a minute and thought it might help others in the future.

LKaemmerling commented 6 years ago

i'm not really sure if it is the best way to add helper methods for this.. Since the naming of the methods says "you can set the BadgeCount for every notification" but it should be " you can set the Badge Count for every notification on iOS"... @Lloople what do you think?

timacdonald commented 6 years ago

Yea, I considered doing incrementIosBadgeCount() but then I thought if in the future you could increment Android badge counts you'd have to change your consuming code.

Where as if its just a generic incrementBadgeCount() you could update the library to do both.

...but after thinking about it, if this is wanted you are probably right: something like incrementIosBadgeCount() is probably the way to go.

Lloople commented 6 years ago

I agree with both of you 😅 I mean, there's a chance OneSignal add this to another platforms like Android or whatever, and your methods contains the word ios explicity on the parameter key. I think those methods should reference ios as Lukas suggested, and in a future we can have a method over it if OneSignal add more platforms like incrementBadgesCount() which will contain the logic for ios and other platforms.

timacdonald commented 6 years ago

Hey @LKDevelopment and @Lloople I've renamed those methods. Let me know if you think that is more suiting or something else.

timacdonald commented 6 years ago

Sweet. I'm already using this, but if you want to do a RC and ping me, I'm happy to pull it in to this app I'm working on and give it a test just to be uber sure everything is working as expected 👍

LKaemmerling commented 6 years ago

@timacdonald thank you. Over the night i've got a little idea how we could clean up the code a little bit. I will merge this and then will overhaul all :) Thank you!

timacdonald commented 6 years ago

sounds good - and thank you both