{"_id":"56cf38da287eb20b009f9ec1","version":{"_id":"561ae15463ef571900ca68d6","project":"561ae15363ef571900ca68d3","__v":3,"createdAt":"2015-10-11T22:23:16.492Z","releaseDate":"2015-10-11T22:23:16.492Z","categories":["561ae15563ef571900ca68d7","56255c864dcb400d00ff4427","56326faf45f2cb0d006be3f1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":1,"category":{"_id":"56326faf45f2cb0d006be3f1","pages":["563274ee49e16d0d001223d7","56cf38da287eb20b009f9ec1"],"project":"561ae15363ef571900ca68d3","version":"561ae15463ef571900ca68d6","__v":2,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-29T19:12:47.370Z","from_sync":false,"order":1,"slug":"examples","title":"Examples"},"githubsync":"","project":"561ae15363ef571900ca68d3","user":"561b45c2ab412a0d004d85d6","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-25T17:24:42.555Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"When running QA on an app, it is often desirable to let your test users see the \"debug\" version of your app before it goes to production. With this approach, you can let users opt-in to debug mode to receive debug-only updates.\n\nNote that the AppHub SDK does not persist the `setDebugBuildsEnabled` option, so you must save the user's choice in `NSUserDefaults`.\n\nFirst, add a method in your app that can be invoked by users. This could be hidden or accessible via a button in your app. You can also wrap this method in `RCT_EXPORT_METHOD` to make it accessible via JavaScript.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"- (void)setDebugMode:(BOOL)isEnabled {\\n [[AppHub buildManager] setDebugBuildsEnabled:isEnabled];\\n [[NSUserDefaults standardUserDefaults] setBool:isEnabled forKey::::at:::\\\"APPHUB_DEBUG\\\"];\\n \\n // Optional: fetch the build right away to update instantly.\\n [[AppHub buildManager] fetchBuildWithCompletionHandler:nil];\\n}\",\n \"language\": \"objectivec\"\n }\n ]\n}\n[/block]\nThen, in `AppDelegate.m`, check for this key in order to set debug builds enabled:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"- (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\\n{\\n BOOL debugIsEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@\\\"APPHUB_DEBUG\\\"];\\n [[AppHub buildManager] setDebugBuildsEnabled:debugIsEnabled];\\n \\n // ...\",\n \"language\": \"objectivec\",\n \"name\": \"AppDelegate.m\"\n }\n ]\n}\n[/block]\nCongrats! You're now able to test builds with other certain users.","excerpt":"","slug":"dynamically-enabling-debug-mode","type":"basic","title":"Dynamically Enabling Debug Mode"}

Examples

Resources

Dynamically Enabling Debug Mode

When running QA on an app, it is often desirable to let your test users see the "debug" version of your app before it goes to production. With this approach, you can let users opt-in to debug mode to receive debug-only updates.
Note that the AppHub SDK does not persist the `setDebugBuildsEnabled` option, so you must save the user's choice in `NSUserDefaults`.
First, add a method in your app that can be invoked by users. This could be hidden or accessible via a button in your app. You can also wrap this method in `RCT_EXPORT_METHOD` to make it accessible via JavaScript.
[block:code]
{
"codes": [
{
"code": "- (void)setDebugMode:(BOOL)isEnabled {\n [[AppHub buildManager] setDebugBuildsEnabled:isEnabled];\n [[NSUserDefaults standardUserDefaults] setBool:isEnabled forKey:@\"APPHUB_DEBUG\"];\n \n // Optional: fetch the build right away to update instantly.\n [[AppHub buildManager] fetchBuildWithCompletionHandler:nil];\n}",
"language": "objectivec"
}
]
}
[/block]
Then, in `AppDelegate.m`, check for this key in order to set debug builds enabled:
[block:code]
{
"codes": [
{
"code": "- (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n BOOL debugIsEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@\"APPHUB_DEBUG\"];\n [[AppHub buildManager] setDebugBuildsEnabled:debugIsEnabled];\n \n // ...",
"language": "objectivec",
"name": "AppDelegate.m"
}
]
}
[/block]
Congrats! You're now able to test builds with other certain users.