-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Option to silence Android foreground notifications #1183
Conversation
adding new key to the documentation
since foreground is not guaranteed in the bundle
Missing some import statements |
@andrewtremblay @xxRockOnxx I don't have enough native android experience to do it myself but could you expand this PR so that the ignoreInForeground feature works for |
|
@andrewtremblay Thanks for working on this! We'll find this very useful. But @xxRockOnxx is right; import statements are needed. Your RNPushNotificationHelper.java needs the following imports:
|
Addressing missing imports from upstream PR
Thanks for reviewing! I added the missing imports (not sure how those were omitted). |
@andrewtremblay-pear hi, looks like I really need this fix) How can I tell to package.json to install package from master directly? Thanks |
@lisichka999 you can use my repo directly by following the git url format So in your package.json, change the react-native-push-notification dependency to https://docs.npmjs.com/files/package.json#git-urls-as-dependencies |
@andrewtremblay Thank you, now I can see your code. I just noticed that it is only related to local notifications, can it work for remote notification as well? Or should I find another fix? |
@lisichka999 Correct. I'm only concerned with scheduled local notifications. But I think remote push notifications use the same helper function that I modified. If you add ignoreInForeground to your remote push payload it might work. If that doesn't work and you want to ignore all foreground notifications, fork my repo & change this line, To this: |
@andrewtremblay Thanks for hint, will try it |
Credit to andrewtremblay zo0r#1183
@Dallas62 Please, consider merging this PR. |
Hi @mtshv for (String d : processInfo.pkgList) {
return true;
} A check of the length should be enough, no ? |
I think it's best if PR author takes a look. @andrewtremblay ^^ |
That might be a better question for the maintainers who last touched isApplicationInForeground in RNPushNotitificationListenerService and/or RNPushNotitificationListenerServiceGcm. I essentially copied the isApplicationInForeground function from there. I agree that the check is weird though. Will update. |
Hi @andrewtremblay |
But I'm still waiting for an answer from the Owner of the repository to be able to release the library 😅 |
A common use case in Android apps is to not show notifications when the app is open in front of the user as they can be distracting (this is default behavior in iOS).
This PR adds the android-only ignoreInForeground property for easier UX parity with iOS notifications.