ti.admob
ti.admob copied to clipboard
[MOD-2470] Ti.AdMob: Add Rewarded Video event
JIRA: https://jira.appcelerator.org/browse/MOD-2470
Description: Add support for Rewarded Video Ad in Android. Add deprecation warnings for the events in the common listener for AdView and Interstitial ad. The target is to follow the format and style in the core Titanium SDK, meaning that they won't be accessible as constants, from the next major version.
Sample:
var Admob = require('ti.admob'),
win = Titanium.UI.createWindow({ layout: 'vertical'}),
rewardedVideo = Admob.createRewardedVideo(),
buttonLoadAd = Ti.UI.createButton({ title: 'Load Ad'}),
buttonShowAd = Ti.UI.createButton({ title: 'Show Ad', enabled: false, touchEnabled: false}),
buttonClaimReward = Ti.UI.createButton({ title: 'Claim Reward', enabled: false, touchEnabled: false}),
reward;
buttonLoadAd.addEventListener('click', function () {
rewardedVideo.loadAd('ca-app-pub-3940256099942544/5224354917');
})
buttonShowAd.addEventListener('click', function () {
rewardedVideo.show();
});
buttonClaimReward.addEventListener('click', function () {
alert('You have received ' + reward.amount + ' ' + reward.type);
buttonClaimReward.enabled = false;
buttonClaimReward.touchEnabled = false;
});
rewardedVideo.addEventListener('adloaded', function () {
buttonShowAd.enabled = true;
buttonShowAd.touchEnabled = true;
});
rewardedVideo.addEventListener('adrewarded', function (rewardItem) {
reward = rewardItem;
buttonClaimReward.enabled = true;
buttonClaimReward.touchEnabled = true;
});
rewardedVideo.addEventListener('adclosed', function () {
buttonShowAd.enabled = false;
buttonShowAd.touchEnabled = false;
});
win.add([buttonLoadAd, buttonShowAd, buttonClaimReward]);
win.open();
Good job!
It would be useful to add extra parameters, as it already happens for the banners, for example
var extras = { 'npa': "1"}; // https://developers.google.com/admob/android/eu-consent#forward_consent_to_the_google_mobile_ads_sdk
var adUnitId = 'ca-app-pub-3940256099942544/5224354917';
rewardedVideo.loadAd(adUnitId,extras);
There is some news about Rewarded Video Ad support in Android?
@Astrovic we are currently working on some parity issues between Android and iOS which we would like to resolve before implementing the new ad types. This will ensure that the new ad types have the same API regardless of platform.
Once #86 and #89 are done we will continue with the new ad types.