We're told, via Apple's docs on startMonitoringSignificantLocationChanges
that the following behavior can be expected by an application using the signification change API:
If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.
Source: Apple Docs
My question is, how would I go about debugging and/or testing this? As soon as I terminate the app I have no idea what's happening (i.e. debugging session gets killed with app). When will I know when or if iOS has launched my app in the background w/ the launchOption key of UIApplicationLaunchOptionsLocationKey
set? More importantly than that, how do I know whether or not the block of code that gets executed is functioning properly? How can I test this scenario rapidly without having to drive around after terminating my app hoping the code I wrote magically works? Any help much appreciate!!
Open the iPhone Settings menu. On an iPhone with an early version of iOS, access the Debug Console through Settings > Safari > Developer > Debug Console. When Safari on the iPhone detects CSS, HTML, and JavaScript errors, details of each display in the debugger.
To detect if an iOS application is in background or foreground we can simply use the UIApplication just like we can use it to detect many other things like battery state, status etc. The shared. application state is an enum of type State, which consists of the following as per apple documentation.
Use Xcode’s Debug > Attach to Process > By Process Identifier (PID) or Name… menu: you can provide the name of your process and Xcode will then wait until it launches to attach and start a debug session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With