IPhone App

s_Fanous7 years ago

Was this issue ever resolved?

Both my wife's iPhone and mine are running 10.2.1 have the global Background App Refresh option enabled. The problem is that Traccar Client does not show up in the list of apps that one can enable/disable background for, so what happens is that iOS kills the Traccar Client when it's low on resources and the updates stop until we manually restart the app, disable "Service status", then enable it again.

TIA

Anton Tananaev7 years ago

it should be on the list because it declares location background mode. I'm not why it's not. Maybe some new changes from Apple.

s_Fanous7 years ago

Anton,

I think I found the issue.

Take a look at this stackoverflow thread.

This link provides an excellent overview of Background Fetch

Enabling Background Fetch mode together with the required code will allow the app to appear under the Background App Refresh apps. Moreover, without this mode the app can get location updates but is not able to update them on the network and that is why it appears that the app has stopped.

P.S. I'm a developer/architect but not an iOS developer, so the above analysis is based on my research the past 2 days.

s_Fanous7 years ago

Actually disregard my previous post. It is inaccurate. I've loaded the code into XCode and what I think I see is identical to what is described here

I've done some code changes and will test them on the iOS simulator and perhaps on my phone and report the results.

Anton Tananaev7 years ago

Great, let me know if you find any solution.

s_Fanous7 years ago

Latest update I have on the default app's behavior is that when the app is running in foreground or background mode it works as expected.

The issue arises when iOS places the app in suspended mode. The very interesting thing I have found from within my Python script logs is that when iOS places the app in suspended mode it will wake it up once per day (Every approximately 86400 seconds) as can be seen from the following excerpt from my script's log. The script runs every 15 minutes, so notice that when the script indicates that the last update was close to 86400 seconds ago the following run shows that the app was woken up by iOS to get the location and perform an update.

2017-02-23 11:31:10.206177: B's iPhone 6 Plus last update was 86077 seconds ago. Check why it hasn't updated recently
2017-02-23 11:46:10.394784: B's iPhone 6 Plus last update was 578 seconds ago. Device was 5 meters away

2017-02-24 11:31:10.281451: B's iPhone 6 Plus last update was 86077 seconds ago. Check why it hasn't updated recently
2017-02-24 11:46:10.375101: B's iPhone 6 Plus last update was 577 seconds ago. Device was 5 meters away

I guess the only remaining piece now is to figure out how to get the app to operate in suspended mode similarly to what it does in background mode. I'll report with my next set of findings.

s_Fanous7 years ago

@Anton

I have done much more reading into iOS development than I intended to :)

Your app has nothing wrong with it. It's iOS that prevents an app from running in the background forever. At some point iOS will determine that it is low on resources and that your app has been in the background for too long, so it'll suspend/terminate the app and at this point users of Traccar Client are SOL.

2 possible ways to wake up a terminated app are

  1. application:didReceiveRemoteNotification:fetchCompletionHandler: -> This would require a push notification to the app followed by a valid reason to perform a background fetch, so even if Traccar were to implement push notification infrastructure, I don't think there is any valid reason to perform a background fetch so I think the app would be rejected if submitted to the AppStore
  2. Significant-change location service -> This would completely defeat the whole purpose of the high level of accuracy required by Traccar client

What I have reverted to, is to build the app using UIBackgroundModes set to continuous, location, unboundedTaskCompletion, and voip. continous and unboundedTaskCompletion are private modes so no way would the app be accepted into the AppStore. The only reason I used the voip mode as well, is because using this mode iOS will automatically start the app after the system rebooting.

Now, my only problem is that I only have a free Apple Developer account so my certificate expires every week and I'm not sure I want to shell out $99/year for this.

P.S. While going through the source code, I noticed that in applicationWillTerminate: you call [userDefaults setValue:nil forKey:@"service_status_preference"]; which sets the Status to off the next time the app is restarted. Why is this the case?

Anton Tananaev7 years ago

If you just want to use it on your personal device, I think from Xcode 7 you don't need developer account to install an app on the phone. You would need it if you want to distribute the app in some way.

As for your question, I set it to "off" to know if the app was terminated. iOS would never re-start the app, so there is not much point in keeping the status "on".

s_Fanous7 years ago

All XCode versions have the same limitation as it's tied to the Free Apple Developer Account. Apparently it used to be that the free profile was valid for 3 months but Apple cut it down to 1 week recently...

Anyways, because I've also included voip as a UIBackgroundModes which automatically launches the app after a system boot I've modified the code by removing the set to "off" in applicationWillTerminate: and adding some code in TCMainViewController:viewDidLoad: to initialize and start self.trackingController

quix7 years ago

interesting! so having a apple developer account for 99$ per year and doing those (simple looking) mods, should make the tracker run 100% all the time?

the last few weeks it has stopped working much more often, several times per week. before, it was maybe once a month (would that case also be handled by the above mods?).

a github-PR would be welcome. without the intention of merging it, just the have the possibility. or maybe a fork.

Marlin4 years ago

Was there any new information on why on one cant see the traccar app in settings on the phone?

i have two apple phones one is a apple iphone 10 and its running the latest 13.3.1 and the other is a Iphone 7 plus running thee same latest updated ios 13.3.1 the iphone 10 shows the tracar app in the settings

the 7 plus does not even after a clean install.

the same software coming from the apple app store, lots of free memory and storage space

any new suggestions?