Displaying iOS iAds only to supported countries

假如想象 提交于 2020-01-04 09:30:16

问题


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?

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

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.


回答1:


(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)

Any suggestions of improvement?

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



回答2:


The iAd framework is a black box. It's use cases are defined in the documentation and you're meant to use it as intended or not at all.

IMHO there's no best way to do this with iAd, only bad ways.

You'd have to do something like:

  1. Work out from within your app the currently supported countries as they can change over time.
  2. Work out where your user is which can change over time.

Both options above have bad side effects.

  1. The network request/parsing to check for the supported iAd countries would be more work than the iAd request.
  2. Using user location from within your app must meet Apple's App Store Review Guidelines

You may fall foul too:

4.4 Location data can only be used when directly relevant to the features and services provided by the App to the user or to support approved advertising uses



来源:https://stackoverflow.com/questions/12684863/displaying-ios-iads-only-to-supported-countries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!