ios - 仅当 Deployment target 大于 6.0 时如何使用 AdMob?

标签 ios admob

我希望我的应用支持 iOS 5.0。但是 Admob 有一个先决条件,即部署目标至少是 6.0。

有没有办法编译我的应用程序,以便 Admob 仅用于运行 iOS >= 6.0 的设备?

我问是因为人们已经对 Apple Watch 做了类似的事情,所以他们可以支持较低的部署目标:iOS7 and Apple Watch

最佳答案

/*
 *  System Versioning Preprocessor Macros
 */ 

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

然后像这样使用

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
    //do admob stuff
}
else {
   //don't do admob stuff
}

还链接了在 ios < 6.0 中不可用的可选框架

附言宏取自 this answer

关于ios - 仅当 Deployment target 大于 6.0 时如何使用 AdMob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29940290/

相关文章:

ios - AdMob 刷新请求

android - 获得用户消息平台 Android 的同意

ios - 在 UIApplicationWillTerminate 上关闭 rootViewController

iphone - iOS 应用程序的文件服务器

flutter - 找不到带有以下内容的广告。原生广告 Flutter google_mobile_ads

android - Play-services-ads 18.0.0 崩溃

android - 回收站 View android 中的 Facebook 原生广告

ios - UIView 上下移动

c++ - 如何在 Xcode 中使用 object-Cpp

ios - 下拉列表中缺少iOS测试飞行版本?