-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Hide iOS push notifications when app is in foreground #835
base: master
Are you sure you want to change the base?
Conversation
Is is possible to have this determined by a configuration option? I'd like to receive notifications in the foreground, especially because cordova-plugin-local-notifications conflicts with this plugin. |
Yes we should keep the default functionality as is and the configuration option should allow hiding the notification when the app is in the foreground. @maitscha could you update the PR and add a new IOS_HIDE_FOREGROUND_NOTIFICATION variable which defaults to false? I'm up to suggestions on better naming for the variable if people have strong opinions on the naming |
Should we use a Swift compiler flag, or what do you mean with "variable"? For example:
|
We need a cordova variable so that users can install the plugin using the command:
|
Unfortunately I never used a |
Yes, usage of variables to configure Cordova plugins is standard. See the docs here: https://cordova.apache.org/docs/en/latest/config_ref/#variable |
@maitscha here's some more info on adding variables to plugins: https://gist.github.com/mlynch/c9a469948680979a8740d68c47d1cf98#adding-variables |
hello, i tried to change this manually in v2.0.1 and made a build with it but it seems not change the behavior. the strange thing i found is that i have another app no2 with same code base where i did not made the change but its working as expected there with "UNNotificationPresentationOptionAlert" with version 2.0.1 . The incoming pushes are recognised with app in foreground but did not show as it should. Any ideas? best regards |
Does this works in the new version of the plugin? This is the really huge issue for me |
@neustart it is not in the newest version of the plugin as it has outstanding modifications. If you would like to make those modifications to get the feature added quicker, please see the Contribution Guidelines. Making the changes yourself is always the fastest way to get something resolved :) |
hi @maitscha, do you have any other idea why this has no effect on my side? I double checked my 2 Apps now about what is used in xcode project at least on file AppDelegate+FirebasePlugin.m but on app 1 and app 2 the setting you suggest in line 168 is "completionHandler(UNNotificationPresentationOptionAlert);" in app 1 it works as expected, in app 2 not. Im not that familiar with the native iOS code but it seems to be related to something else from a logical point of view. best regards |
If you want to hide the notifications for a running in-foreground app, you have to use the option |
@maitscha i understood and tried this. But it wont work on my side. Also, it does not explain why it hides as expected in one app with UNNotificationPresentationOptionAlert, but not in the other one. |
@maitscha I have the same issue. which file I should modify? |
@laychar Is that question related to the pull request? If so, I believe you need to modify the install scripts as that is the outstand issue with the current PR in its current state. If you are talking about working around the issue, please use the issue #817 to have that conversation as the PR should be related only to proposed code changes. |
Thank you for your answer. But I want to change UNNotificationPresentationOptionAlert to UNNotificationPresentationOptionNone. |
@ColDrekken Did you solve this problem? I modify UNNotificationPresentationOptionAlert to UNNotificationPresentationOptionNone like you did. But It did not work as your app. |
@laychar unfortunately no... but my feeling is that this is not really related to UNNotificationPresentationOptionAlert Option. As i said i have 2 Apps which are just have another branding. Both uses V2.0.1 of the plugin and both have "UNNotificationPresentationOptionAlert " in AppDelegate+FirebasePlugin.m but it only works in one app as expected. And i did not found the difference yet. @maitscha @briantq im not that familiar with Swift or Objective C. Could there be another part that cause that behavior? What could be the reason that it works in one app but not in the other with same code? |
@ColDrekken I don't know the code intimately, but you can check out FirebasePlugin.m and AppDelegate+FirebasePlugin.m as those two files contain most of the business logic. You should be able to put breakpoints in via XCode and trace what is happening. Sorry I can't be more help |
Thank you for your kindness!
I will try try it more.
2018년 9월 28일 (금) 오전 6:38, Brian Bauman <notifications@github.com>님이 작성:
… @ColDrekken <https://github.com/ColDrekken> I don't know the code
intimately, but you can check out FirebasePlugin.m and
AppDelegate+FirebasePlugin.m as those two files contain most of the
business logic. You should be able to put breakpoints in via XCode and
trace what is happening. Sorry I can't be more help
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#835 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AotrAa7fz06NctnHXYEsT0H2uzeHPZU_ks5ufUVHgaJpZM4WfvbT>
.
|
I have also tried manually changing that line to |
me too.
2018년 10월 12일 (금) 오전 10:50, wildhart <notifications@github.com>님이 작성:
… I have also tried manually changing that line to
UNNotificationPresentationOptionNone then built and installed the app,
and the notifications still popup even when the app is open.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#835 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AotrASl-uQR_4K90TS2HCJfW6vJlzO4oks5uj_VcgaJpZM4WfvbT>
.
|
Hi guys, I am facing same issue on iOS 12 device and doing the change proposed in this PR is fixing it for me. |
Hi @ALL. Meanwhile i personally think this issue is not related to UNNotificationPresentationOptionNone Or Alert. Because I got three apps which have nearly the same code base and using 2.0.5 and only two of them have the problem. One is working as expected but I could not figure out yet what was the difference... |
@ColDrekken are you testing your different apps on a single device ? single iOS version ? For me, with a device on iOS 12, switching from UNNotificationPresentationOptionAlert to UNNotificationPresentationOptionNone on the completionHandler makes all the difference and clearly fix the issue. I can't say however if it's true for other iOS version. |
When will this get merged? |
Any news on this one? |
Haha, de si Igore. Sasa iz Altee ovde. Ja koristim ovaj fork https://github.com/jfougere/cordova-plugin-firebase koji ima ovo sredjeno. |
This hides the push notification in iOS if the app is in foreground by using
UNNotificationPresentationOptionNone
instead ofUNNotificationPresentationOptionAlert
in the completion handler.