简体   繁体   中英

Detect if app is running on iOS beta?

I have some iAd/AdMob supported apps on the iOS app store. I notice every time a iOS beta comes out, ad requests plummet. I'm assuming this is due to many people running the beta OS, and therefor almost always get a iAd test ad. Is there some way my code can detect if an app is on a beta OS version? This way I could default to AdMob so I get some revenue.

It's not a particularly pretty way to do it, but you could read the device version and compare it to the highest current known release version, and revert to AdMob if the device version is higher.

This will get the device version as a string:

[[UIDevice currentDevice] systemVersion]

You can convert this to a float value and compare it to a hard-coded version, but this would mean deploying a new version once the new iOS is released:

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.3) 
{
    // revert to AdMob...
}

As a slightly better solution you could request the current maximum iOS release version from a website... just drop a iosversion.txt file on your site with the contents "4.3" and use that to control the switch.

Unfortunately there doesn't seem to be a [[UIDevice currentDevice] isBeta] type method.

According to rumors, the iOS version 8 will come in September.

So, you can use:

NSDate *today = [NSDate date];

NSString *releaseDateString = @"2014-09-15 00:00:00";
NSDateFormatter *dateFormater = [[NSDateFormatter alloc] init];
[dateFormater setDateFormat:@"yyyy-MM-DD HH:mm:ss"];
NSDate *release = [dateFormater dateFromString:releaseDateString ];
NSComparisonResult comp = [today compare:release];

if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 && result == NSOrderedAscending) return @"Beta";
else return @"Release Version";

or get the title of url: https://www.apple.com/ios/ and check iOS ?

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString *title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
    title = [title stringByReplacingOccurrencesOfString:@"Apple - iOS " withString:@""];
    int version = [title intValue]; // 6, 7, 8...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM