Sử dụng phương thức show
để hiển thị quảng cáo đã tải và lệnh ủy quyền UnityAdsShowDelegate
để xử lý logic cho các sự kiện hiển thị khác nhau. Trong ví dụ này, một nút kích hoạt quảng cáo:
// 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); }
Bước tiếp theo: Để cải tiến quá trình triển khai, hãy tham khảo tài liệu về Cách triển khai quảng cáo có thưởng trong iOS.