Test & Troubleshoot
Enable Debug Mode
Debug mode allows you to view debug logs for the Movement SDK so you can quickly spot any configuration errors and better understand SDK states. For iOS, there is a method named
presentDebugViewController(parentViewController:) in the
PilgrimManager that will present a view controller from your current view controller with the debug logs you can display in your host app. Developers who wish to display debug mode can do so with the following implementation instructions:
- Configure the SDK
You should have already configured the Movement SDK in your application’s AppDelegate.
- Enable Debugging in AppDelegate
didFinishLaunchingWithOptions method where you configured the
MovementSdkManager, add the following line of code:
MovementSdkManager.shared().isDebugLogsEnabled = true
This will begin logging and saving debug statements that will be displayed in debug mode.
- Present the Debug View Controller
presentDebugViewController(parentViewController:) method returns a view containing debug mode. You can choose how you’d like to display this (e.g., through a button, a gesture, etc.). Here is an example of how to initialize and present it:
Test a Visit
With the SDK properly configured, the delegate method(s) should be hit whenever you arrive or depart at one of our 105M+ places around the world. In order to test your visit callback without physically walking around, we provide a testing class
visitTester. This class can be used to simulate visits with different confidence levels and location types.
For example, the following code will simulate a visit at a given lat/lng:
MovementSdkManager.shared().visitTester.fireTestVisit(location: CLLocation(latitude: 37.7904311, longitude: -122.4066613))
Reasons for a getCurrentLocation nil or error response
There are a couple reasons why calling
getCurrentLocation would return an error or a nil value:
Lack of network connectivity: The most likely reason the SDK cannot retrieve the device's current location would be because the API request has failed to make a proper connection to the Foursquare server.
Lack of location permissions: If the
LocationSubscriberis not allowed to get location info. This means that the proper location permissions have not been properly set or granted by the user. For foreground usage, the When In Use permissions are required. And if being used in the background, it will require the Location Always permission.
CLLocation timeout: If
CLLocationdoesn’t return a location to us within the timeout value we specify and fails to resolve a location.
Updated about 2 months ago