Debug Mode: iOS

Debug mode allows you to view debug logs for the Pilgrim 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:

1. Configure Pilgrim

You should have already configured Pilgrim in your application’s AppDelegate (if not, see this).

2. Enable Debugging in AppDelegate

In the didFinishLaunchingWithOptions method where you configured the Pilgrim Manager, add the following line of code:

PilgrimManager.shared().isDebugLogsEnabled = true

This will begin logging and saving debug statements that will be displayed in debug mode.

3. Present the Debug View Controller

The 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:

PilgrimManager.shared().presentDebugViewController(parentViewController: self)

Debug Mode: Android

Debug mode allows you to view debug logs for the Pilgrim SDK so you can quickly spot any configuration errors and better understand SDK states. In Android, the class PilgrimSdkDebugActivity contains the view for debug mode and is available to developers using the SDK. Developers who wish to display debug mode can do so with the following implementation instructions:

1. Configure Pilgrim

See the quickstart guide to ensure Pilgrim is configured correctly.

2. Add debug dependency

In your build.gradle file’s dependencies, include:

com.foursquare:pilgrimsdk-debugging:2.2.0

3. Turn logging on

When using the builder to instantiate Pilgrim, make sure you enable debug logs and set the log level to Debug:

val builder = PilgrimSdk.Builder(this)
    .consumer(BuildConfig.PILGRIM_API_CLIENT_KEY, BuildConfig.PILGRIM_API_CLIENT_SECRET)
    .logLevel(LogLevel.DEBUG)
    .enableDebugLogs()
PilgrimSdk.with(builder)
PilgrimSdk.Builder builder = new PilgrimSdk.Builder(this)
    .consumer(BuildConfig.PILGRIM_API_CLIENT_KEY, BuildConfig.PILGRIM_API_CLIENT_SECRET)
    .logLevel(LogLevel.DEBUG)
    .enableDebugLogs();
PilgrimSdk.with(builder);

4. Decide View Options

You can show debug mode through a gesture or button. Decide on how you want to show debug mode and ensure you have the application’s context available to start the activity.

5. Start Activity with New Intent

val debugIntent = Intent(this, PilgrimSdkDebugActivity::class.java)
startActivity(debugIntent)
startActivity(new Intent(this, PilgrimSdkDebugActivity.class))

To avoid errors, the variable this should be of type Context

Missing test visits

By default, Android’s debug mode events do not auto update, requiring you to close and reopen the debug mode view to see new activity (including when triggering test visits from the debug mode). You can enable auto autodating by turning on the “Tail” feature available from the debug mode’s menu.

Next Steps

Geofences

Was this page helpful?
Yes
No
Thank you!