I am currently developing a todo app (android) using ionic framework which can synchronize with the pouchdb when it is connected to the internet, and also user will receive notification in background when new task has been added to the database and sync to the phone.
So if I want the user to receive the notification in background the whole app should be also running in background so that it will detect any new task sync to the phone and generate local notification to notify the user about the incoming new task.
So my question is: is it possible to make my whole cordova/ionic app or whole app.js to be running in background as a background service?
You can try to use this plugin:
https://github.com/MobileChromeApps/cordova-plugin-background-app
eventually, if you need, in conjunction with:
cordova-plugin-background-mode to manage background mode and simple notifications
cordova-toforeground to force the to come back on foreground
Related
I want to track user location continuously and update it to server. Also user can set alarm to start tracking. User can kill app or terminate it so how to run a background service to track continuous location and post it to server? Is it possible to achieve it in flutter without writing native code in both android and ios platform?
You are right !! You can also go with flutter background service plugin and do some customization then maybe it's work
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.
I need to know about how to run a background service to give notifications in cordova mobile application. I went through a plugin this but in that example when i clicked the 'Interval' option which is triggering notification for every minute when only app was opened or paused. It wasn't triggering any notification when app was killed(Swipe out from recent tasks) on background. So is there any alternative option to run the process in background in cordovaapplications
According to phonegap/Cordova documentation their is no way to run
background service because phone can not execute javascript when your
app is not running.Yet no plugin was available to perform this task
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."
I am working on an cordova app using ionic framework with angular.
I want app to start in background when internet connection become available so that i can fetch some notifications from server.
Is there any way to start app in background. I can keep app in background but for this it has to be in started once.
I trink you have to create a BroadcastReceiver to be notified when an connection is established. When this happends you could start a Service which fetch some data. For your cordova app you have to write an Cordova Plugin.