I'm attempting to create a new View Controller for displaying rewarded videos to users using either UnityAds and Vungle (depending on which is available).
After a Vungle video view, the VungleSDKDelegate
will call vungleSDKwillCloseAdWithViewInfo
which I have implemented as such:
- (void)vungleSDKwillCloseAdWithViewInfo:(NSDictionary *)viewInfo willPresentProductSheet:(BOOL)willPresentProductSheet {
NSLog(@"vungleSDKwillCloseAdWithViewInfo");
[self finishVideoView];
}
And finishVideoView
as:
- (void) finishVideoView {
NSLog(@"finishVideoView");
[self dismissViewControllerAnimated:YES completion:nil];
}
This works great, when it's done, the view controller is dismissed and the app resumes. However, when I attempt to do this method in Unity's UnityAdsDelegate
's method unityAdsDidFinish
, the view controller just hangs out there and never dismisses.
- (void)unityAdsDidFinish:(NSString *)placementId withFinishState:(UnityAdsFinishState)state{
NSLog(@"unityAdsDidFinish");
[self finishVideoView];
}
Any ideas why? It seems that the unityAdsDidFinish
callback happens right after I hit the x at the top of the finished video.
I thought it might be a timing issue so I also tried doing:
[self performSelector:@selector(finishVideoView) withObject:nil afterDelay:1.0];
But that does not seem to help either.
I ended up decided to avoid waiting on the delegate methods and instead implementing finishVideoView
in my ViewController's viewWillAppear
method. It seems to work now - whenever my view controller appears again, it checks the BOOL to see if a video has played, if so, it finishes the controller.