Is the Ionic Application operating in background mode?

Asked 1 years ago, Updated 1 years ago, 100 views

Hello.

Currently, we are creating apps through ionic-framework.

Due to the nature of the app, the latitude and longitude values must be updated periodically on the server

If the user leaves the app with a back button, can the server API send the location information value continuously?

Or, is there a better way than the above way? I also registered question on StackOverflow. Please let me know if there is a better way!

Thank you for reading this long article.

geolocation ionic-framework

2022-09-21 18:30

1 Answers

You can send location information to the server even in the background state. However, Android needs to consider this because it can terminate the background process depending on the situation to secure resources. The way to prevent the app from shutting down even in the background is to use the foreground service.

If you run the foreground service, it is classified as a highly important process, so it is unlikely that you will be terminated even if you leave the app with the back button. For example, think about how Android's music or exercise apps show the current status in the status bar even if you leave the app.

For more information and code, read Run service in the foreground of the following document.

If the transfer of the current location is not important enough to run as a foreground service (which can be ignored if the app is terminated by the system), it might be a good idea to run it as a normal service.

Read the process life cycle part of the following document.

The important thing is to make sure that the icon-framework supports this. Looking at the homepage, there is an API as below. Regardless of whether this API runs as a foreground service, it would be good to test it yourself.


2022-09-21 18:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.