-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat(ios, messaging): Allow notifications in foreground on iOS, configure in firebase.json #6407
feat(ios, messaging): Allow notifications in foreground on iOS, configure in firebase.json #6407
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
// if list or banner is true, ignore `alert` property | ||
if (banner || list) { | ||
if (banner) { | ||
if (@available(iOS 14, *)) { | ||
presentationOptions |= UNNotificationPresentationOptionBanner; | ||
} else { | ||
// for iOS 13 we need to set `alert` | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} | ||
} | ||
|
||
if (list) { | ||
if (@available(iOS 14, *)) { | ||
presentationOptions |= UNNotificationPresentationOptionList; | ||
} else { | ||
// for iOS 13 we need to set `alert` | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} | ||
} | ||
} else if (alert) { | ||
// TODO: Remove `alert` once iOS 14 becomes the minimum deployment target | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} |
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.
Same logic in notifee
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.
yes - I was silently reading those as they went through, so I followed things as they went to the final solution, this looks good to me
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.
Looks good to me, thanks a lot for this! Normally I tell people to use Notifee for device-local-anything when it comes to notification presentation but including at least a minimum for foreground (similar to background) is very nice.
One quick question: is there a feature gap on the android side as well for notifications showing up in the default state?
// if list or banner is true, ignore `alert` property | ||
if (banner || list) { | ||
if (banner) { | ||
if (@available(iOS 14, *)) { | ||
presentationOptions |= UNNotificationPresentationOptionBanner; | ||
} else { | ||
// for iOS 13 we need to set `alert` | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} | ||
} | ||
|
||
if (list) { | ||
if (@available(iOS 14, *)) { | ||
presentationOptions |= UNNotificationPresentationOptionList; | ||
} else { | ||
// for iOS 13 we need to set `alert` | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} | ||
} | ||
} else if (alert) { | ||
// TODO: Remove `alert` once iOS 14 becomes the minimum deployment target | ||
presentationOptions |= UNNotificationPresentationOptionAlert; | ||
} |
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.
yes - I was silently reading those as they went through, so I followed things as they went to the final solution, this looks good to me
Codecov Report
@@ Coverage Diff @@
## main #6407 +/- ##
===========================================
- Coverage 72.31% 25.84% -46.47%
===========================================
Files 109 97 -12
Lines 4655 4289 -366
Branches 1048 1048
===========================================
- Hits 3366 1108 -2258
- Misses 1211 2581 +1370
- Partials 78 600 +522 |
I suppose no. As you can see this doc, foreground presentation options for Remote Notification is only for iOS. |
Hmm, I got no diff even after executing |
Hmm - I think of Notifee as going "higher" in the stack, we are below them (in my mental model - that is, lower level) and firebase-android-sdk would be even lower than that, with the GCM libraries and FCM receipt on the device as the bottom / most inner part. My question was aimed at: as GCM/FCM hits the device and firebase-android-sdk executes things / potentially booting the app and loading the Java code then the javascript bundle (similar to firebase-ios-sdk loading the objective-c code in I have not actually tested this (at least not recently enough to remember) so I'm unsure - I was mostly curious for the results of any testing if you've done it. I'm okay with just doing an iOS feature and waiting for someone interested (or myself) to do same for android if there's a feature gap, I was just curious if you knew since I assume you're testing this with a react-native app so you looked at iOS and could probably check android with same codebase / testing setup |
I see this:
|
(I pushed a commit with that diff to your branch as an attempt at higher velocity - hopefully no offense is taken! :-) ) |
Thank you for updating the doc!
I tested this feature by patching
Maybe we can explore the code around |
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.
looks even better now, thanks for organizing + patching up the spellcheck dictionary
🤔 perhaps this collided with #6406 and this needs a rebase against current main ? |
def4def
to
027192c
Compare
Rebased using the latest main 👍 |
I'll be shocked if this doesn't do it - I'm about to be done for the night so won't see the result for hours but I imagine it will be either all green or perhaps a flaky-CI-test or something. But it all looks good now to me |
Description
Resolve this TODO comment (
"in a later version allow customising completion options in JS code"
).Added a key to configure
UNNotificationPresentationOptions
Related issues
banner
andlist
options toIOSForegroundPresentationOptions
by ken0nek · Pull Request #463 · invertase/notifeealert
by ken0nek · Pull Request #465 · invertase/notifeeRelease Summary
Can configure
UNNotificationPresentationOptions
on iOS viafirebase.json
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter