Skip to content

Instantly share code, notes, and snippets.

@vijaysharm
Created January 21, 2019 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaysharm/a220a3474622176b06a88f65fbb4d34f to your computer and use it in GitHub Desktop.
Save vijaysharm/a220a3474622176b06a88f65fbb4d34f to your computer and use it in GitHub Desktop.
/*
This example shows how to use getDistributionStatus method in the TestFairy SDK.
getDistributionStatus queries the server about the app version currently running on device, and checks
to see if "Distribution" is set to "Enabled" in Build Settings page.
The example below will close the app if the distribution was disabled. If there is a newer version of
this app uploaded to TestFairy, and it is set to "Distribution" => "Enabled", then the code will open a url to
the new version, offloading to the operating system to install the app.
*/
[TestFairy getDistributionStatus:appToken callback:^(NSDictionary<NSString *,NSString *> *response, NSError *error) {
if (error != nil) {
if ([@"enabled" isEqualToString:[response objectForKey:@"status"]]) {
NSString *urlString = [response objectForKey:@"autoUpdateDownloadUrl"];
NSURL *url = [NSURL URLWithString:urlString];
if (url != nil) {
[[UIApplication sharedApplication] openURL:url];
}
}
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment