Home / GitHub Page

Android (background) sync interval

Hi,

I have been searching for a Google Keep alternative for a while and finally came to Joplin which works absolutely great.

I have however one question about the android application.
In the settings there is an option for the sync interval. Does this mean it also syncs in the background?

Example: When i edit a note in windows on day 1 and let it sync (encrypted) to dropbox. Then don’t open Joplin on android for a few days. Will it still have the edited note as offline due to background sync? So when on for example day 4 i don’t have an internet connection and i open Joplin i can still continue the work in the edited note?

Thanks in advance

7 Likes

Anyone who can shed some light on this?

Currently the mobile app doesn’t sync when it’s not open. When you open it, it will sync as long as it stays open.

Thank you for your reply.

I hope there are plan to eventually have an option to let it background sync when changes happen so you always have the most recent files even when there is no internet.

3 Likes

Please add background syncing. I find it annoying to have to open the app to keep my notes up to date.

2 Likes

It’s a limit of react native and the new Android Doze and App Sleep API. But if you find a way, please let us know.

will it be possible to have joplin sync when you open the app to “kinda give it background sync”?

3 Likes

Will this work? I would like to have a way for Joplin to sync automatically

1 Like

It might. @laurent can we trigger a sync when we bring the app to the foreground?

1 Like

Hmm, but it means we don’t respect the sync interval anymore. Like if someone has 1h as sync interval and opens the app every 5 min they’ll get a lot of unwanted syncs.

The sync interval is useless on mobile anyway, because it doesn’t sync in the background.

If it weren’t, I’d agree with you.

Isn’t there at least an option to prevent screen from turning off while the sync is running?

Why useless? It’s respected while the app is running. So if you have set it to 10 min it would do this:

  • Open the app after 4 min: nothing happen
  • Open 3 min later: nothing happen
  • Open 4 min later: sync

Of course it would be much better if it could run in the background. It might be possible but in general background tasks are unreliable, with mobile manufacturers randomly killing background services as they please, so getting a RN app working in this hostile env is likely to be difficult.

Hmm, ok. In that case setting it to 1 minute might be similar to syncing when opening/bringing it to the foreground.

I have set it to 10 minutes, but it usually never syncs when I open it again after an hour. I’ll have to investigate this in more detail.

I think in general there are 2 sync issues on mobile:

  • no background sync
  • device goes to sleep during sync
1 Like

My point exactly. When I make a lot of changes and want to make sure they are downloaded to my phone, I basically have to babysit it, opening joplin and tapping periodically until it finishes. Last time I had 500 changed sync items, it took quite a while.

2 Likes

React Native doesn’t support long timers so timing is done based on PoorManIntervals, which creates timers that activate based on user activity (specifically, based on the Redux actions). So if you open the app and do nothing, sync won’t happen.

Maybe the solution would be to also make the timers activate based on when the user opens the application (it just means calling the “update()” method). Or maybe it’s a different issue and for some reason the PoorManIntervals class doesn’t work properly.

@laurent & @tessus, would this library work?

Right now I’m re-synchronizing my notes on Android for the n-th time and background sync would be really nice. I have almost 4000 objects now and this collection is constantly growing. While I understand that there are technical limitations, other users probably won’t be as forgiving.

Did you have the time to check out the library mentioned by @ee_joplin ?

If you check out the Nextcloud client on iOS, to get syncing to work in the background, the devs had to force using GPS tracking to allow this since Apple implemented something similar. Since Joplin already has GeoLocation tagging built in, could a similar approach work for Android background syncing with the caveat that it’s definitely an anti-privacy feature?

This particular comment, despite being not the best, explains it:

Did you revoke access to the stock Apple system functions of GPS. I don’t know the English settings, maybe Settings -> Data Protection -> Location Services -> System Services (As i said i don’t know the English words, these are translated from my language) because if you disable all of these your phone will never recognise that it’s been moved somewhere else

Basically, GPS tracking has to always be enabled for Joplin and when it updates, it’ll ping Joplin to sync.