I am using the local notification plugin for Cordova.
When the app goes to the background on Android and when the app comes to the foreground the notifications are hidden from the notification area.
I can still get them from getById.
How can I get a notification that stays until I cancel or clear them?
Or is this Android specific behaviour?
You should check out the backgroundmode plugin to be able to control it (and the notifications) when it goes to the background. Also from the same author, a good notification plugin.
"Cordova plugin to prevent the app from going to sleep while in background.
Most mobile operating systems are multitasking capable, but most apps dont need to run while in background and not present for the user. Therefore they pause the app in background mode and resume the app before switching to foreground mode. The system keeps all network connections open while in background, but does not deliver the data until the app resumes."
Related
As the title says, I'm scheduling some notifications for android on unity but I would like them to not appear if the app is open (only foreground and closed). I didn't find any information on the documentation. I guess I can cancel them right before the fire time, but is there any other option?
I have a situation on my React Native app, where user can start a timer and isRunning and startTime states are stored in the app so that it can display current running time when the app is in foreground even though the user quits the application at some point and opens it again.
Is there a way to show notification icon on status bar when the timer is running, but user has quit the application to indicate that the timer is currently "running" (actually it is not doing any operations on background) on background?
I have encountered some apps that display a silent notification that is not directly closable after I have quit the app, but I haven't seen a situation where status bar notification is present (together with notification) until some condition is met after the app is quit by the user.
Is there a way to achieve this? I am using react-native-push-notification and Firebase to push notifications in my app overall.
React-Native manages only Active and Background/Inactive/Foreground state. When user kill the app. JS engine shuts down.
All you can use is Local Notification and Scheduled Notification. I also have one app in which user set a reminder time. And notification invoke at that specified time.
Using Firebase I guess you need to call api after some specific interval for push notification from server side.
I am not an expert in background services or android development but here is my thought... I believe you could dig in and write some java android code for a background unstoppable service (persistent on app close or background states). You can do this by creating a bridge and using native modules to manage your background services. I came across a great resource on medium that details the process of creating a background service, a broadcast receiver and maintaining Headless instance even when the app is closed or the device restarts.Hope that helps you achieve your goal.
Edit
This ready made package will help you with better. Check it out. You actually don't have to write native android java code at all.
Customers can turn off push notifications at the app level. When that happens, we all know the the notification tray UI will not show up. But,
Does GCM/FCM (android) and APNS (iOS) continue to deliver notification to the customer's phone regardless ?
Specifically, on android & iOS, will I be able to execute some logic in the push event listener regardless of whether the user turned the push notifications on/off ?
In Android, when we disable push notifications, does the OS automatically unregister the app from GCM/FCM ?
Note:
I am NOT interested in background app refresh on iOS or background refresh through WorkManager on Android. I am NOT interested in iOS silent notifications or other kinds of Background Executions.
My question is specifically whether the code block is invoked (or not) when push notifications are turned off at app level (using the toggle).
I am not sure about the android, but in iOS this thing is possible.
You can do this but just keep in mind, that Background App Refresh is enable in device.
For more details, look into this link
https://www.urbanairship.com/blog/watch-list-ios-8-opt-in-changes
I hope you get your answer from above link
I have used GCM to get push notifications, now if I Force stop the app from the settings on the Android device, will it be able to get push notifications?
I have read many posts that say in this case an app cannot receive notifications.
Is there any possibility to get notifications?
Once you force-stop your app from Settings, your code will not run until something manually runs one of your components (ie the user manually launches an activity).
Therefore after force-stopping your app from Settings, you will not receive GCM messages.
If you want to get notifications you have to manually restart your app.
This is by design since Android 3.1.
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
when the app is initially installed (before the user runs something in
the app) or
after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols
The requirement is for an enterprise application. The application will be started on device boot. It will be running in the background and the user should not be able to disable or Stop the application. In Android a user can go to Settings->Application->Manage Application and stop my application. Is there any way to prevent this from happening?
No there is not. You can prevent Android from stopping the application by utilizing a Service and marking it as a foreground service, though this will require your application to display an icon in the status bar.
You can not make your application live forever, but it depends on what you really want to do. It's possible to receive a lot of events of the mobile and execute code even if your Activity/Service is not running. You can use BroadcastReceivers to look for interesting events and then start a service. I do it for an Enterprise Application that sends an event to a main server when the user has received/made a call.