在提供激励之前如何查看 vungle 广告是否已加载并完成?

How to see if a vungle ad has loaded and been completed before providing an incentive?

在我当前的应用程序中,我正在通过 vungle 实施激励广告。用户播放广告后,我想对其进行编码,以便在广告已加载且广告已完成时,我的应用会将您重定向到另一个名为 Continue 的 SKScene。但是,我不确定如何检查广​​告是否已 completed/loaded 以有效地重定向用户。我想确保没有漏洞,并且如果没有互联网 connection/if 广告无法加载,则无法获得奖励。任何帮助将不胜感激,在此先感谢。下面是我当前的代码

在AppDelegate.m

NSString* appID = @"XXXXXXXX";
VungleSDK* sdk = [VungleSDK sharedSDK];
// start vungle publisher library
[sdk startWithAppId:appID];

在GameViewController.m下ViewDidLoad

[[NSNotificationCenter defaultCenter] addObserver:self     selector:@selector(handleNotification:) name:@"showVideo" object:nil];
Under handleNotification:(NSNotification *)notification

if ([notification.name isEqualToString:@"showVideo"]) {
    VungleSDK* sdk = [VungleSDK sharedSDK];
    NSError *error;
    [sdk playAd:self error:&error];
}

在GamePlay.m下一个按钮class

[[NSNotificationCenter defaultCenter] postNotificationName:@"showVideo" object:nil];

也在GamePlay.m

- (void)vungleSDKwillCloseAdWithViewInfo:(NSDictionary *)viewInfo willPresentProductSheet:(BOOL)willPresentProductSheet {
//Verify that the view was completed before rewarding the user
BOOL completedView = [[viewInfo valueForKey:@"completedView"] boolValue];
if (completedView) {


    Continue *Continue1 = [Continue sceneWithSize:self.frame.size];
    SKTransition *transition = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:0.75];
    [self.view presentScene:Continue1 transition:transition];
    [self.button play];
}
}

您需要实现 VungleSDK 委托,它可以在 advanced settings guide 中的委托方法下找到。

回调 (void)vungleSDKwillCloseAdWithViewInfo: 将向您传递一个 viewInfo 字典。

如果 key completedView returns YES,您可以继续并奖励用户的查看。