Do location services not update on someone elses test iPhone? - ios

I am not getting background updates on another test iPhone. I have an application built and running fine on my own test iPhone. The simulator works fine as well with testing. Both can keep pulling the location services while in the background. I test this by spitting the lat and long into the debug area. Even when in the background, both spit the lat and long and keep chugging through.
When I put it on my roommates iPhone to test it, it does not keep updating in the background. Other than that, it works fine. I went into the development part in his settings and could not find anything there either. Is there something I am missing with allowing an the app to run in the background?

Go to Settings -> Privacy -> Location Services (should be ON) -> Name of your app (check if you allow using location)

Check Background App Refresh setting in Settings/General
Apple - getting the user's location
When a user disables the Background App Refresh setting either
globally or for your app, the significant-change location service
doesn’t relaunch your app. Further, while Background App Refresh is
off an app doesn’t receive significant-change or region monitoring
events even when it's in the foreground.

Related

iOS App Restarts After Changing Revoked Privacy Settings

No code to show, but merely a question on something that I'm sure has irked other developers/users.
When a user has revoked/denied permission to their Photos for a given app and then later changes to "Read and Write", the app resets/refreshes when opening it back up. Is there a way to not have the app reset/refresh when navigating back to the app? This is a concern because when the user is prompted to change their Photos permission, the user is deep within the app and now loses any progress made on that page after the permission is changed.
I am currently using Xamarin Essentials with Xamarin Forms, if that helps any.
It is designed by iOS system and your app is forced to restart when you change the privacy settings. I think there is no way to get around it.
You can try to save the state in the method applicationDidEnterBackground and restore it when user come back again after changing the setting.
Refer:
Having app restart itself when it detects change to privacy settings
App crashes in background while changing permission
There are some situations where your app gets killed and restarted: when it is swiped out, when your device is running out of power are turned off by the user, when the app is moved to the background and there isn’t enough memory for all apps, and as you noticed, when certain settings change.
The reason for the restart on settings change is that your app might be doing things that get disallowed, or it might never notice things that are suddenly allowed; many apps check these things once when the app starts, so restarting it is guaranteed to make it work correctly.
You should have code that saves the application state when the app goes in the background, and restores the state when the app is launched. That fixes not just your problem with permission changes, but will also restore the app after being swiped out or killed while in the background.

How can we get updated location after app is terminated?

We have used
significantLocationChange(https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant_change_location_service)
for update location but it gives location update sometimes and so it
is not consistenly giving the location update.
What is the best way to get updated location frequently when app is
in terminated stage (not in foreground / not in background)
You have to enable Background modes for Location updates for your app. You can do this by selecting your Project -> Capabilities -> Background Modes and enable Location updates.
There is no way to do that, IMHO. If the app is terminated you will get no frequent updates, it was the users choice to terminate your app and Apple respects this. iOS does not collect location data in the background and handles it over to your app when your app is started again.

App not working in Background when iPhone is restarted

I have an app where I have enabled Background mode i.e, Location Updates. The app works in background perfectly until its restarted. Once restarted, the app doesn't get the location updates (The app isn't running). Anyway we can make the app run even after restarting the phone?
Chandan I give you very best solution from the below reference.
Kindly go through this

Continue location updates after iOS device is rebooted

In iOS7, will an app that has requested continuous location updates (not signification changes/ region monitoring) be relaunched after a reboot?
When I reboot my phone, the app is suspended, then terminated. When I restart my phone, the app stays in the terminated state until I manually start it.
I've tried adding a background fetch with minimum refresh intervals to relaunch the app, but that's never called either.
In the apple doc it explains that if I enable significant location changes, it will launch my app from a terminated state, but does not mention anything about continuous location updates.
Any recommendations on how to get my app to continue receiving updates after relaunch?
I don't think this is going to be possible because its no use if your app launches in the background anyway because the monitoring for location updates initial request HAS to be made while your app is in the foreground.
If this request is made while the app is in the background then it doesn't work. You somehow have to get your app into the foreground so you can start the process of getting updates again.
You could add significant location changes temporarily as an experiment so that your app gets woken up and then see if you can get location updates once your app has been launched into a background state but I'm 99% sure you won't be successful.
I have tested for many months, the only possible way for iOS to relaunch the app for new location updates after the app is terminated/suspended is using the locationManager method startMonitoringSignificantLocationChanges. If you use startUpdatingLocation, iOS will not relaunch the app for you and hence the app can not get the location update.
If you want to understand the details about the differences between getting location update in the background vs getting location update even when the app is kill/terminated/suspended, please see:-
A) Getting location update when the app is In the background, please see: Background Location Services not working in iOS 7
B) Getting location update when the app is suspended/terminated, please see: How to Get Location Updates for iOS 7 and 8 Even when the App is Suspended
I have written 2 very long article explaining the different between the 2 scenario. The source codes for the above 2 scenario are also available on the GitHub.

How to get geofencing didEnterRegion delegate method call when app is closed

So when the app is closed (not in background, but totally closed), how app can get didEnterRegion delegate method call when user enter a region? And how I can simulate that in simulator.
Thanks.
Your app will be reopened (into the background) to handle the update. You can not test this in the simulator.
In the simulator go to the 'Debug :: Location' submenu and either select a test location or enter lat+long data under 'Custom Location...'
If your application is not running, then it can't get location services. However, if you can add a 'Passbook' aspect to your Application then you can get Passbook to monitor a location for you. See https://stackoverflow.com/a/14040276/1286639
If you use region monitoring, your app will be restarted by the system.
It's hard to debug because when you close the app, the debugger will detach.
Try this:
Start the app on a connected phone and simulate new locations using Xcode. To do this, create a GPX file with multiple locations. When the debugger is running, there is a little location arrow next to the start/stop/pause buttons that allows you to select the GPX file with your track. Xcode will then simulate moving from point to point in the GPX. You can verify this by opening the Maps app and watching the location move around.
When you kill your app, the debugger will detach, but you can reattach with Debug->Attach to process->Your App Name. That will get you the console back, but you won't be able to continue simulating the location in the running app. Also it's not clear if the simulated location resets back to normal mode when you do this. I get different results all the time.
Region monitoring is flaky at best. I have been trying to get reliable results since iOS 5 and it's a real mess with unpredictable results...

Resources