Closed daviddean99 closed 1 year ago
Hi there! Versions in use of notifee etc? Operating system in use (iOS, Android, what versions)? Some sample code that demonstrates how you are currently posting the notification would help
Thanks!
Hi @mikehardy,
Running latest notifee 1.3.1:
:notifee_react-native:version set from package.json: 1.3.1 (1,3,1 - 1003001)
:notifee_react-native:android.compileSdk using custom value: 29
:notifee_react-native:android.targetSdk using custom value: 29
:notifee_react-native:android.minSdk using custom value: 16
Testing against Android 10 (API 29) with emulator in Android Studio.
Here is the code:
async function onDisplayNotification(sender, body, icon) {
// Create a channel
const channelId = await notifee.createChannel({
id: 'priority',
name: 'High Priority',
});
// Display a notification
await notifee.displayNotification({
title: sender,
body: body,
android: {
channelId,
largeIcon: icon,
},
});
};
I tried adding "importance: AndroidImportance.HIGH" to both functions, but then the notification doesn't fire at all.
Thanks.
Mmm I think this will need to be a native feature enhancement https://stackoverflow.com/a/55635238
Ok, thanks @mikehardy.
I'll test later on a physical device just to make sure it's not an artefact of the emulator.
In terms of raising a feature enhancement, would that be with the react native team?
It'll be with me and/or @helenaford and here we are 😁
Ok, thanks @mikehardy!
What I'm trying to implement in my app with Notifee is two tiers of notification.
1 - a "normal" priority notification which is visible on the lock screen and will temporarily illuminate the screen upon notification, similar to when an SMS or other "system" notification is received;
2 - a "high" priority notification which is also visible on the lock screen but will continuously illuminate the screen and play a continuous notification sound until the notification is acknowledged, similar to a pager alert for on-call teams.
The screen illumination seems to be a bit hit-and-miss on different devices. Some Android devices do illuminate the lock screen upon receipt of a notification while others do not. It would be nice for consistency of user experience for Notifee to support the explicit illumination of the screen to ensure cross-device support.
Thanks.
Hi @daviddean99 did you get a solution for continuously illuminate the screen & play a continuous notification sound ?? @mikehardy could you please help with this requirement?
Hi @mathews-p, no, unfortunately we didn't. If it were added to notifee then we would be very happy!
I believe that is an alarm, not a notification, those are different parts of device API surface area entirely, there is probably a package for this?
Hmm - I took a look through the react-native ecosystem at alarm packages (there were a couple) but they are all lightly used (judging by github star popularity, npmjs.com download rate), while at the same time also fairly simple and with significant overlap to the notification and time trigger functionality here.
It is definitely a different are of device APIs but this could be a reasonable addition here on a roadmap pending thoughts of others @helenaford ?
Hi @mathews-p, no, unfortunately we didn't. If it were added to notifee then we would be very happy!
thank you @daviddean99 for the update.
Hey folks! Any news about adding support to light up the screen when receiving a new notification?
Hi @gustavogialim this isn't on our roadmap on the moment, but adding it as a element on the notification settings could be an acceptable PR, last time I researched it appeared this would work for android
Mmm I think this will need to be a native feature enhancement https://stackoverflow.com/a/55635238
I see. Nice, if I get some time I can try to create a PR for this implementation, thanks for the answer!
@mikehardy Do you have an contribution doc?
I tested the native solution and it worked fine in the local tests. So since I've never contributed to a react-native
lib before I would be happy to follow the best practices to contribute, create the branch, open PR and etc...
Hey awesome. Yeah we have https://github.com/invertase/notifee/blob/main/CONTRIBUTING.md - it lists out how to run the tests and the example app etc. Contributing to a react-native lib is a bit different then native because once you get native working you still have to wrap it in javascript and expose that somehow, so that's an extra complexity, and then (sadly) we have one more layer which is that Notifee actually has two native chunks. There is the "core library" and there is "the react-native bindings between core library on one side and javascript on the other". Which is a fair bit of plumbing
But! Since I think this would go in notification settings, hopefully it is a bit more like adding one more wire into an existing conduit you can follow through easily, instead of laying whole new conduit. Apologies if that metaphor is terrible.
Either way, fork, clone, make a branch, post a PR and we can go from there. Always happy to collaborate on PRs, that's how software's made...
Wonderful explanation @mikehardy, 'react-native' really let all the process a little more complex, but as you said, the implementation is just an android notification setting, so was not so hard to find my way to implement it.
I just opened the PR, I really hope it is right, if not please let me know how about any wrong or missing thing. Let's get this new enhancement on!
Observation: The implementation was a simple setting to light up the screen when a notification is displayed, in the future I think is really possible to have a better complexity around this, an example could be light up the screen when the notification is 'high' priority, anyway, just saying that I implemented a basic and beginning for something better :)
Thanks again for the support!
@gustavogialim thanks for the p/r, just reviewed. 🥳 😎
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
I'm successfully displaying notifications on Android device lockscreens.
But the device screen does not light up when the notification is triggered.
When I press a button to wake up the screen then the notification is displayed.
Is it possible to trigger the screen to light up for a period when displaying the notification on the device lock screen?
Thanks.