检测应用程序是否在 iOS beta 上运行?

发布于 2024-11-16 14:16:38 字数 166 浏览 3 评论 0原文

我在 iOS 应用商店中有一些支持 iAd/AdMob 的应用。我注意到每次 iOS 测试版发布时,广告请求都会直线下降。我假设这是由于许多人运行测试版操作系统,因此几乎总是会收到 iAd 测试广告。有什么方法可以让我的代码检测应用程序是否处于测试版操作系统版本上?这样我就可以默认使用 AdMob,从而获得一些收入。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

方圜几里 2024-11-23 14:16:38

这不是一个特别漂亮的方法,但您可以读取设备版本并将其与当前已知的最高版本进行比较,如果设备版本更高,则恢复为 AdMob。

这将以字符串形式获取设备版本:

[[UIDevice currentDevice] systemVersion]

您可以将其转换为浮点值并将其与硬编码版本进行比较,但这意味着在新 iOS 发布后部署新版本:

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

作为一个稍微更好的解决方案,您可以从网站请求当前最高 iOS 发行版本...只需在您的网站上放置一个内容为“4.3”的 iosversion.txt 文件,然后使用它来控制开关。

不幸的是,似乎没有 [[UIDevice currentDevice] isBeta] 类型的方法。

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.

风筝在阴天搁浅。 2024-11-23 14:16:38

据传言,iOS 8 版本将于 9 月发布。

因此,您可以使用:

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";

或获取网址的标题: https://www.apple.com/ios/< /a> 并检查 iOS ?

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

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...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文