admob 广告代码参考 iOS 奖励视频
来源:互联网 发布:淘宝女装推荐 知乎 编辑:程序博客网 时间:2024/05/22 12:23
Request rewarded video
GADRewardBasedVideoAd
has a singleton design, so the following example shows a request to load an ad being made to the shared instance:
[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
withAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
To allow videos to be preloaded, we recommend calling loadRequest:
as early as possible (for example, in your app delegate's application:didFinishLaunchingWithOptions:
method).
Always test with test ads
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
The easiest way to load test ads is to use our dedicated test ad unit ID for iOS rewarded video:
ca-app-pub-3940256099942544/1712485313
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
For more information about how the Mobile Ads SDK's test ads work, see Test Ads.
Set up event notifications
To set up event notification, insert the line shown in bold before your loadRequest:
call:
[GADRewardBasedVideoAd sharedInstance].delegate = self;
[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
withAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
GADRewardBasedVideoAdDelegate
notifies you of rewarded video lifecycle events. You are required to set the delegate prior to loading an ad. The most important event in this delegate isrewardBasedVideoAd:didRewardUserWithReward:
, which is called when the user should be rewarded for watching a video. You may optionally implement other methods in this delegate.
Here is an example that logs each event available in GADRewardBasedVideoAdDelegate:
:
- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
didRewardUserWithReward:(GADAdReward *)reward {
NSString *rewardMessage =
[NSString stringWithFormat:@"Reward received with currency %@ , amount %lf",
reward.type,
[reward.amount doubleValue]];
NSLog(rewardMessage);
}
- (void)rewardBasedVideoAdDidReceiveAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
NSLog(@"Reward based video ad is received.");
}
- (void)rewardBasedVideoAdDidOpen:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
NSLog(@"Opened reward based video ad.");
}
- (void)rewardBasedVideoAdDidStartPlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
NSLog(@"Reward based video ad started playing.");
}
- (void)rewardBasedVideoAdDidClose:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
NSLog(@"Reward based video ad is closed.");
}
- (void)rewardBasedVideoAdWillLeaveApplication:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
NSLog(@"Reward based video ad will leave application.");
}
- (void)rewardBasedVideoAd:(GADRewardBasedVideoAd *)rewardBasedVideoAd
didFailToLoadWithError:(NSError *)error {
NSLog(@"Reward based video ad failed to load.");
}
Display rewarded video
It is a best practice to ensure a rewarded video ad has completed loading before attempting to display it. The isReady
method indicates that a rewarded video ad request has been successfully fulfilled:
if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
}
Additional resources
Samples
- Rewarded Video example on GitHub: Swift | Objective-C
- admob 广告代码参考 iOS 奖励视频
- admob 广告代码参考 安卓 奖励视频
- admob 广告代码参考 iOS banner广告
- admob 广告代码参考 iOS 弹窗广告
- 移动广告工厂:Unity中的AdMob奖励视频
- admob 广告代码参考 安卓 弹窗广告
- admob广告代码参考 安卓 banner广告
- 如何测试您的AdMob奖励广告?
- AdMob奖励广告的入门指南
- U3D Admob广告代码
- iOS 使用admob广告
- IOS 下使用AdMob广告
- iOS如何植入admob广告
- IOS 下使用AdMob广告
- iOS如何植入admob广告
- IOS 下使用AdMob广告
- cocos2dx-ios接入admob广告
- iOS 开发 初级:插入Admob 广告
- Linux安装python2.7
- Linux中二进制软件包和源码软件包
- 在.NET MVC中查找.json文件时提示添加MIME 错误404.3
- 正则表达式 身份证、邮箱、手机号
- 大屏做成这样,领导不重用你都难
- admob 广告代码参考 iOS 奖励视频
- Could not find a storyboard named 'Main' in bundle NSBundle </Users/liuyuhang/Library/Developer/Core
- Linux学习9:任务计划crontab
- Hadoop介绍
- Android关于图片压缩
- netscope,Can't infer network data shapes
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- Linux中二进制软件包和源码软件包
- Win7 64位系统下CPU版Tensorflow的安装