Skip to content
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

notification clear when app close from home btn in android #1658

Open
ghost opened this issue Aug 8, 2018 · 11 comments
Open

notification clear when app close from home btn in android #1658

ghost opened this issue Aug 8, 2018 · 11 comments

Comments

@ghost
Copy link

ghost commented Aug 8, 2018

notification clear when app close from home btn in android

  • Plugin version: 0.9.0-beta.2
  • Platform: Android
  • OS version: 7.1.1
  • Device manufacturer / model: Motorola - G5 s plus
  • Cordova version (cordova -v): 8.0.0
  • Cordova platform version (cordova platform ls): 6.3.0* Plugin config

Expected Behavior

LocalNotification should be not close when app close by home button in android

Tell us what happens instead

Loacl notification close whn app close

@Tawpie
Copy link

Tawpie commented Aug 8, 2018

@rajan2ram try beta.3

@hordesalik
Copy link

@Tawpie it's not fixed in beta.3

@Tawpie
Copy link

Tawpie commented Sep 14, 2018

@ghost since the easy answer isn't the correct answer, can you be more descriptive with what you mean by your expected behavior "Local notification should not be close"? My expectations are that when the user hits the home button, the app and all of its windows will go away (close). All of my app's notifications that were in the notification shade will also be cleared and will no longer appear in the notification shade.

Can you be very specific about what are you wanting to happen? (for example: when the app is running and a local notification is displayed, when I hit the home button the local notification should _____________ )

@rwillett
Copy link
Collaborator

AFAIK this is the expected and default behavior on both IOS and Android.

If you want to keep the notifications visible you have to reschedule them again, however this is not the behaviour that most applications should use.

@hordesalik
Copy link

when the app is running and a local notification is displayed, when I hit the home button the local notification should still be visible. For example how it does Google drive when user is downloading file.
Once download complete, notification added and it still visible even if user close Google drive application until it is clicked or dismissed manually. I expect the same behaviour. Maybe it can be configured with some params.

@Tawpie
Copy link

Tawpie commented Sep 14, 2018

ah. That simply won't happen. The phone's operating system (Android/iOS) controls what happens when the home button is tapped and there's nothing your app or its plugins can do to change that. Right now, mobile devices will close all windows associated with your app when you tap the home button.

Google (being the owner of Android) may give its apps extra permissions to do special things, but third party apps and especially ones based on packagers like Cordova have no ability to modify the OS behavior. It's a lost cause…

@hordesalik
Copy link

Hmmm. Maybe we should use push notifications instead...

@hordesalik
Copy link

Accroding to Android documentation:

A notification remains visible in the notification drawer until dismissed by the app or the user.

Is it not about local notifications? So maybee this is a cordova related problem, not the OS itself?

@rwillett
Copy link
Collaborator

rwillett commented Sep 17, 2018

AFAIK the action of starting an app up removes all the notifications. I know that when I send push notifications down to both IOS and Android, starting the app up OR resuming the app from the background means the notifications are removed. That's the action for local notifications, OneSignal and PushWoosh remote notifications. We have always assumed that is the case and indeed we write code to reschedule local notifications that we want the user to see.

@hordesalik
Copy link

hordesalik commented Sep 17, 2018

@rwillett yes, maybe when the app is starting it works so, but notification get removed once app getting to the background mode. That's the main problem.

BTW, I tested in iOS and it works as expected. When I preseed "home", application got into background and notification still present in notifications area. Then I locked and unlocked iOS - notification still there. I closed and re-ran application - notification has not been removed. It still visible in notifications area until user manually remove it.

For Android, once application lose focus - all notifications are getting removed.

UPD:
Tested with autoClear: false - nothing changed
I consulted with Android developer and he confirmed - this is not default behaviour and sent me a link with quotes

A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app.

A notification remains visible in the notification drawer until dismissed by the app or the user.

link2

Notifications provide short, timely, and relevant information about your app when it’s not in use.

So in current implementation for android 8 notification are quite useless.

Also in example there is a notification on locked screen, but currently if I will lock screen - notification will disappear.

@lokkeshjaya
Copy link

This behavior might be seen when you use local notification plugin in combination with phonegap-push plugin. phonegap-plugin-push by default clear all pending notifications when the app go in pause. To fix this behavior, just set the clearNotifications to "false":

var push = PushNotification.init({ android: { clearNotifications:"false" } });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants