Debug Button on

Debug Button

If you're having trouble configuring the SDK or seeing your Button you can enable debug logging when you initiate your Button to see what's going on. To do so, add the following line when initiating Button.

Button.shared().setDebugLoggingEnabled(true)
[[Button sharedButton] setDebugLoggingEnabled:YES];

Your new applicationDidFinishLaunching function will look like this:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  // Debugging enabled
  Button.shared().setDebugLoggingEnabled(true)

  // Replace YOUR_BUTTON_APP_ID with your App ID from the Button Dashboard https://app.usebutton.com
  Button.shared().configure(withApplicationId: "YOUR_BUTTON_APP_ID") { configError in
    if let error = configError {
      print("Error: \(error.localizedDescription)")
    }
  }

  return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  // Debugging enabled
  [[Button sharedButton] setDebugLoggingEnabled:YES];

  // Replace YOUR_BUTTON_APP_ID with your App ID from the Button Dashboard https://app.usebutton.com
  [[Button sharedButton] configureWithApplicationId:YOUR_BUTTON_APP_ID completion:^(NSError *error) {
    if (error) {
      NSLog(@"Error: %@", error.localizedDescription);
    }
  }];

  return YES;
}

Note: You should not ship to the App Store with this enabled.

With debug logging enabled, Button will log to the standard log output with the success or failure of the following operations:

  • Button SDK Initialization
  • Creating a session with Button
  • Rendering a Button
  • Interactions with the Commerce Card
  • All operations which failed (including simply not matching an action for the current context) will print with the log statement a Request ID in the format req-xxxxxxxxx.

If you can't figure out why your Button isn't working, contact us and send this token to our support team and we can then investigate why things aren't working as expected.