我正在尝试停止所有的广告后,在应用程序购买iOS使用Heyzap SDK。
我试过了:
-(void) OnRemoveADS {
...
[self buyFeatureRemoveADS];
[HeyzapAds nil];
[HeyzapAds removeFromSuperview];
HZInterstitialAd = nil;
}它们都会产生Xcode错误。
我知道我将不得不从不同的位置关闭它们,因为我的横幅广告是从间隙单独初始化的。
类似于此方法中的else语句:
-(id) init {
if (self = [super init]) {
g_bRemoveADS=[[NSUserDefaults standardUserDefaults] boolForKey: @"REMOVEADS"];
if(!g_bRemoveADS)
{
[[[[UIApplication sharedApplication] keyWindow] rootViewController] view];
HZBannerAdOptions *options = [[HZBannerAdOptions alloc] init];
//options.presentingViewController = self;
[HZBannerAd placeBannerInView:self.view
position:HZBannerPositionBottom
options:options
success:^(HZBannerAd *banner) {
NSLog(@"Ad Shown!");
} failure:^(NSError *error) {
NSLog(@"Error = %@",error);
}];
}
else {
// Stop banner ads here
}在MKStoreManger中,有几种删除广告的方法:
- (void) buyFeatureRemoveADs {
[self buyFeature:featureRemoveADSId];
}静态字符串:
static NSString *featureRemoveADSId = IAP_RemoveADS;发布于 2015-09-25 05:55:53
我是Heyzap的iOS工程师。
当广告被禁用时,不显示间隙广告、视频广告或激励广告非常容易:只需在显示它们之前检查g_bRemoveADS BOOL值:
g_bRemoveADS = [[NSUserDefaults standardUserDefaults] boolForKey: @"REMOVEADS"];
// For HZInterstitialAd, HZVideoAd, and HZIncentivizedAd, just check the BOOL to see if an ad should be shown
if (!g_bRemoveADS) {
[HZInterstitialAd show];
}对于HZBannerAd,有三种情况需要考虑:
下面是横幅的代码:
if (!g_bRemoveADS) { // case (1)
[HZBannerAd placeBannerInView:self.view
position:HZBannerPositionBottom
options:options
success:^(HZBannerAd *banner) {
if (g_bRemoveADS) { // case (2)
// Just discard the banner
[banner removeFromSuperview];
} else {
// Keep a reference to the current banner ad, so we can remove it from screen later if we want to disable ads.
self.currentBannerAd = banner;
}
NSLog(@"Ad Shown!");
} failure:^(NSError *error) {
NSLog(@"Error = %@",error);
}];
}我创建了一个单独的disableAds方法,该方法设置NSUserDefaults中的值并销毁当前横幅(如果有)。
- (void)disableAds {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"REMOVEADS"];
[currentBannerAd removeFromSuperview]; // case (3)
}当前的HZBannerAd接口有点复杂。我们正在开发一个更简单的界面,它将为您处理所有这些复杂性。
https://stackoverflow.com/questions/32771225
复制相似问题