在 iOS 中实现插屏广告

使用 show 方法显示已加载的广告,并使用 UnityAdsShowDelegate 代理来处理各种显示事件的逻辑。在此示例中,按钮会触发广告

// Implement a button that calls the show method when clicked:
#pragma mark : Buttons
- (IBAction)showInterstitialButton:(UIButton *)sender {
    [UnityAds show:self placementId:@"Interstitial_iOS" showDelegate:self];
}
 
// Implement callbacks for events related to the show method:
#pragma mark: UnityAdsShowDelegate
- (void)unityAdsShowComplete:(NSString *)placementId withFinishState:(UnityAdsShowCompletionState)state {
    NSLog(@" - UnityAdsShowDelegate unityAdsShowComplete %@ %ld", placementId, state);
}
 
- (void)unityAdsShowFailed:(NSString *)placementId withError:(UnityAdsShowError)error withMessage:(NSString *)message {
    NSLog(@" - UnityAdsShowDelegate unityAdsShowFailed %@ %ld", message, error);
    // Optionally execute additional code, such as attempting to load another ad.
}
 
- (void)unityAdsShowStart:(NSString *)placementId {
    NSLog(@" - UnityAdsShowDelegate unityAdsShowStart %@", placementId);
}
 
- (void)unityAdsShowClick:(NSString *)placementId {
    NSLog(@" - UnityAdsShowDelegate unityAdsShowClick %@", placementId);
}

下一步:若要改进实现,请参阅 在 iOS 中实现奖励广告 文档。