sle*_*rfx 2 objective-c ios iad
似乎苹果只向极少数国家提供iAds服务.因此,当在非iAd支持的国家/地区使用应用时,我想停止发送iAd请求.那么最好的方法是什么?
我问这个问题,因为我最近收到了来自Apple通过iAd网络消息部分的以下消息.
iAd网络最近在加拿大推出.广告现已投放到美国,加拿大,英国,德国,意大利,西班牙,法国和日本应用商店的应用.请将您的应用配置为仅在这些国家/地区投放广告.
小智 8
(我在StackOverflow中的第一篇文章!)
我也试图解决这个问题.似乎没有一种完美的方式来做到这一点.我的方法是使用用户区域设置的国家/地区.(见下文)
有任何改进建议吗?
// Indicate if the iAds framework is supported for this particular device
+ (bool) iAdsIsSupported
{
// List of supported countries for iAds
static NSSet* supportedCountries = nil;
if (supportedCountries == nil)
{
supportedCountries = [[NSSet setWithObjects:
@"ES", // spain
@"US", // usa
@"UK", // united kingdom
@"CA", // canada
@"FR", // france
@"DE", // german
@"IT", // italy
@"JP", // japan
nil] retain];
}
// Check if the country is in the supported countries
// http://stackoverflow.com/questions/3940615/find-current-country-from-iphone-device
NSLocale* currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
return [supportedCountries containsObject:countryCode];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2526 次 |
| 最近记录: |