问题
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:
- Work out from within your app the currently supported countries as they can change over time.
- Work out where your user is which can change over time.
Both options above have bad side effects.
- The network request/parsing to check for the supported iAd countries would be more work than the iAd request.
- 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