gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:36 25 4
gpt4 key购买 nike

苹果似乎只向极少数国家提供 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com