仅在支持的国家/地区显示iOS iAd [英] Displaying iOS iAds only to supported countries

查看:92
本文介绍了仅在支持的国家/地区显示iOS iAd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

It seems apple serves iAds only to very few number of countries. So I would like to stop sending iAd requests when app is being used in a non-iAd-supported country. So what is the best way to do this?

我之所以问这个问题,是因为我最近通过iAd网络的消息"部分收到了来自Apple的以下消息.

I'm asking this question because I recently received following message from Apple via iAd network's messages section.

iAd网络最近在加拿大启动.广告现在正在 投放到美国,加拿大,英国,德国,意大利,西班牙, 法国和日本的App Store.请为广告配置您的应用 仅在这些国家/地区提供服务.

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上的第一篇帖子!)

(My very first post in StackOverflow!)

我也在努力解决这个问题.似乎没有完美的方式来做到这一点.我的方法是使用用户区域设置的国家/地区. (请参见下文)

I am also trying to solve this. It seems there is not a perfect manner to do it. My approach is to use the country of the user locale. (see below)

有什么改进建议吗?

// 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];
}

这篇关于仅在支持的国家/地区显示iOS iAd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆