-
Im using Continuous Running app service -> https://docs.zepp.com/docs/guides/framework/device/app-service/ Inside it, in 1 min loop it does (in promise chain):
AppService looks like this:
and Main loop looks like this:
For some reason loop works fine for some debuging period of time, but when i go sleep with it turned on, it fails to work in nighttime, later on morning it looks like whole appService is dead, and i didn't get any error notification nor systme log inside zepp app. In documentation there's "The "App Service" will exit only when the exit service API is actively called or when system-related restrictions are triggered." |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I am having a similar problem. My application is receiving data from the internet. During the day it usually works fine. But at night the data is not updated. I attribute this to the fact that at night the phone does not see user activity and limits background processes. Usually after that in the morning the service works normally, but not always. |
Beta Was this translation helpful? Give feedback.
-
After some testing (Thanks to new alert) It looks like app-service goes down when bluetooth disconnects, and app-service tries to do web request (Every 1 min). AppService then will go dark, and won't restart or after bluetooth is connected. Only way to get it running then is to open Zepp-app on ios phone, and then kill/start app service again. @MyoungXUE Do you have some idea why it does happen? I'd assume that app-service would just throw some error if network request fails, but not die and be able to continue working in loop when bluetooth goes back online. |
Beta Was this translation helpful? Give feedback.
I got help from @SashaCX75 in the Discord channel — this advice turned out to be the key:
You can see how this approach works in one of his projects:
[weather_alarm_service.js](https://github.com/SashaCX75/Weather-service/blob/main/app-service/weather_alarm_service.js)
— structure of the app-service[settings.js](https://github.com/SashaCX75/Weather-service/blob/main/page/settings.js)
— alarm configuration exampleAfter applying this, my app started running 24/7 without interruption.
Key points from my implementation
In the
app-service
, make sure to define:onInit
onEvent
And every exit point should call
appService.exit()
— including insidetry/catch
.Example from
app-service/backgr…