在我当前的应用程序中,我正在通过 vungle 实施激励性广告。用户播放广告后,我想对其进行编码,以便如果广告已加载且广告已完成,我的应用程序会将您重定向到另一个名为 Continue 的 SKScene。但是,我不确定如何检查广告是否已完成/加载以有效地重定向用户。我想确保没有漏洞,并且如果没有互联网连接/如果广告没有加载,则无法访问激励。任何帮助将不胜感激,在此先感谢。以下是我当前的代码
在 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 中的按钮类下
[[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];
}
}