objective-c - 仅向受支持的国家展示 iOS iAds

标签 objective-c ios iad

苹果似乎只向极少数国家提供 iAd。因此,当应用程序在不受 iAd 支持的国家/地区使用时,我想停止发送 iAd 请求。那么最好的方法是什么?

我问这个问题是因为我最近通过 iAd 网络的消息部分收到了 Apple 的以下消息。

The iAd Network has recently launched in Canada. Ads are now being served to apps on the U.S., Canada, U.K., Germany, Italy, Spain, France, and Japan App Stores. Please configure your apps for ad serving only in these countries.

最佳答案

(我在 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];
}

关于objective-c - 仅向受支持的国家展示 iOS iAds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12684863/

相关文章:

iphone - 如何通过 iPhone 托管网站?

iphone - 如何使文本字段在 iphone 中只接受 4 位数字或数字

ios - 使用 IOS 相机,得到 <wait_fences : failed to receive reply: 10004003>

javascript - 如何获取 Cordova 的谷歌地图API key

ios - iAd 横幅不工作

ios - 以编程方式将 UIButton 添加到 UINavigationBar 的 subview 并且触摸事件未注册

ios - 如何将项目添加到 UITableView?

ios - SizeToFit() 无法正常使用\n?

iphone - 如何在 Xcode 3.2.5 中实现 iAds

objective-c - 更改 iAd 位置和展示位置