Rewarded Video Integration for iOS (Chinese)
第 1 步. 实现激励视频Delegate
ironSource SDK 会在广告可用及完成时触发多个事件通知您,以便您知道何时奖励用户。 SDK 将就下列所有可能事件通知您的delegate:
OBJECTIVE-C
#pragma mark - ISRewardedVideoDelegate //Called after a rewarded video has changed its availability. //@param available The new rewarded video availability. YES if available //and ready to be shown, NO otherwise. - (void)rewardedVideoHasChangedAvailability:(BOOL)available { } //Called after a rewarded video has been viewed completely and the user is //eligible for reward.@param placementInfo An object that contains the //placement's reward name and amount. - (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo { } //Called after a rewarded video has attempted to show but failed. //@param error The reason for the error - (void)rewardedVideoDidFailToShowWithError:(NSError *)error { } //Called after a rewarded video has been opened. - (void)rewardedVideoDidOpen { } //Called after a rewarded video has been dismissed. - (void)rewardedVideoDidClose { } //Note: the events below are not available for all supported rewarded video ad networks. Check which events are available per ad network you choose //to include in your build. //We recommend only using events which register to ALL ad networks you //include in your build. //Called after a rewarded video has started playing. - (void)rewardedVideoDidStart { } //Called after a rewarded video has finished playing. - (void)rewardedVideoDidEnd { }
SWIFT
//MARK: ISRewardedVideoDelegate Functions /** Called after a rewarded video has changed its availability. @param available The new rewarded video availability. YES if available and ready to be shown, NO otherwise. */ public func rewardedVideoHasChangedAvailability(_ available: Bool) { } /** Called after a rewarded video has finished playing. */ public func rewardedVideoDidEnd() { } /** Called after a rewarded video has started playing. */ public func rewardedVideoDidStart() { } /** Called after a rewarded video has been dismissed. */ public func rewardedVideoDidClose() { } /** Called after a rewarded video has been opened. */ public func rewardedVideoDidOpen() { } /** Called after a rewarded video has attempted to show but failed. @param error The reason for the error */ public func rewardedVideoDidFailToShowWithError(_ error: Error!) { } /** Called after a rewarded video has been viewed completely and the user is eligible for reward. @param placementInfo An object that contains the placement's reward name and amount. */ public func didReceiveReward(forPlacement placementInfo: ISPlacementInfo!) { }
第 2 步. 向您的用户显示视频广告
通过正确实现激励视频委托及其函数,您即可通过 rewardedVideoHasChangedAvailability 接收可用状态。 当广告可用状态改变时,下列委托函数将会通知您:
OBJECTIVE-C
/** *Called after a rewarded video has changed its availability. *@param available The new rewarded video availability. YES if available *and *ready to be shown, NO otherwise. */ (void)rewardedVideoHasChangedAvailability:(BOOL)available { }
SWIFT
/** Called after a rewarded video has changed its availability. @param available The new rewarded video availability. YES if available and ready to be shown, NO otherwise. */ public func rewardedVideoHasChangedAvailability(_ available: Bool) { }
或者,按以下方式直接调用请求广告可用状态:
OBJECTIVE-C
[IronSource hasRewardedVideo];
SWIFT
IronSource.hasRewardedVideo()
一旦广告网络有可用视频时,您即已准备好向用户展示此视频广告。此时是插入触发器以鼓励用户观看视频广告的理想时机。 调用下列方法向用户展示视频广告:
OBJECTIVE-C
[IronSource showRewardedVideoWithViewController:(UIViewController *)viewController placement:(nullable NSString *)placementName];
SWIFT
IronSource.showRewardedVideo(with: <UIViewController>, placement: <String?>)
利用 ironSource 广告位置布置工具,您可自定义优化激励视频体验。此工具使您可以依奖励不同而从不同位置向用户展示视频。您可使用以下函数,定义您希望展示广告的确切位置。请前往广告展示位置文档以了解更多细节信息。 要获取关于每个广告展示位置的具体奖励详情,您可调用以下代码:
OBJECTIVE-C
[IronSource rewardedVideoPlacementInfo:(NSString *)placementName]; if(pInfo != NULL) { NSString * rewardName = [pInfo rewardName]; NSNumber * rewardAmount = [pInfo rewardAmount]; }
SWIFT
let placementInfo = IronSource.rewardedVideoPlacementInfo(<;placementName: String>) if placementInfo != nil { let rewardName = placementInfo.placementName let rewardAmount = placementInfo.rewardAmount }
除 ironSource 广告展示位置外,您现在可为所选展示位置广告配置频次和花费预算节奏设置。频次和花费预算节奏可通过限制在给定时间内的总广告投放数来提升应用的用户体验。请在此处了解更多关于频次和花费预算节奏的信息。 OBJECTIVE-C SWIFT [IronSource isRewardedVideoCappedForPlacement:@"Placement"];
IronSource.isRewardedVideoCapped(forPlacement: <String>)
全新!动态 UserID 验证 AdRewarded Transactions 动态 UserID 是在会话中可更改的参数,其可在服务器至服务器广告奖励回调中接收。此参数可帮助验证 AdRewarded transactions ,且其必须在调用 ShowRV 前设置。
OBJECTIVE-C
[IronSource setDynamicUserId:@"DynamicUserId"];
SWIFT
IronSource.setDynamicUserId(<dynamicUserId: String>)
第 3 步. 奖励用户
ironSource SDK 将在用户每次成功完成一条视频时触发 didReceiveReward 事件。在奖励前,您将会通过以下deldgate函数获得通知。
展示位置对象同时包括了您在 ironSource 管理员中定义的奖励名称 & 奖励总额 :
OBJECTIVE-C
//Called after a rewarded video has been viewed completely and the user is //eligible for reward. //@param placementInfo is an object that contains the placement's reward //name and amount. - (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo { NSNumber *rewardAmount = [placementInfo rewardAmount]; NSString *rewardName = [placementInfo rewardName]; }
SWIFT
/** Called after a rewarded video has been viewed completely and the user is eligible for reward. @param placementInfo An object that contains the placement's reward name and amount. */ public func didReceiveReward(forPlacement placementInfo: ISPlacementInfo!) { }
完成! 您现在已在应用中设置好投放激励视频。