cordova-plugin-admob-baidu
v1.0.13
Published
Cordova Plugin for Baidu MSSP Ads
Downloads
17
Maintainers
Readme
Baidu Admob for MSSP / Cordova Plugin
通过 Javascript 调用百度广告联盟(MSSP)SDK 接口,渲染广告内容
官方 SDK 下载:
NPM
https://www.npmjs.com/package/cordova-plugin-admob-baidu
Installation
通过 Cordova Plugins 安装
$ cordova plugin add cordova-plugin-admob-baidu
通过 URL 安装
$ cordova plugin add https://github.com/liangyongxiong/cordova-plugin-admob-baidu.git
Usage
YOUR_APP_ID
: 应用媒体ID
YOUR_POSITION_ID
: 广告位ID
横幅广告(Banner)
align
: 显示位置(top-顶部,bottom-底部)
var banner = cordova.BaiduAdMob.BannerAd.show({
app: YOUR_APP_ID,
position: YOUR_POSITION_ID,
align: 'bottom',
}).addEventListener('onSuccess', function(event) {
console.log('Baidu AdMob banner onSuccess');
setTimeout(function() {
banner.hide();
}, 3000);
}).addEventListener('onError', function(event) {
console.log('Baidu AdMob banner onError');
}).addEventListener('onClose', function(event) {
console.log('Baidu AdMob banner onClose');
}).addEventListener('onClick', function(event) {
console.log('Baidu AdMob banner onClick');
});
插屏广告(Interstitial)
type
: 插屏类型(1-其它,2-视频播放前倒计时,3-视频播放中暂停)
var interstitial = cordova.BaiduAdMob.InterstitialAd.show({
app: YOUR_APP_ID,
position: YOUR_POSITION_ID,
type: 3,
}).addEventListener('onSuccess', function(event) {
console.log('Baidu AdMob interstitial onSuccess');
setTimeout(function() {
interstitial.hide();
}, 5000);
}).addEventListener('onError', function(event) {
console.log('Baidu AdMob interstitial onError');
}).addEventListener('onClose', function(event) {
console.log('Baidu AdMob interstitial onClose');
}).addEventListener('onClick', function(event) {
console.log('Baidu AdMob interstitial onClick');
});
开屏广告(Splash)
bottom
: 底部填充区域,包括图片路径和填充区域高度(单位:dp)
var splash = cordova.BaiduAdMob.SplashAd.show({
app: YOUR_APP_ID,
position: YOUR_POSITION_ID,
bottom: {
image: 'images/bottom.jpg',
height: 120,
},
}).addEventListener('onSuccess', function(event) {
console.log('Baidu AdMob splash onSuccess');
}).addEventListener('onError', function(event) {
console.log('Baidu AdMob splash onError');
}).addEventListener('onClose', function(event) {
console.log('Baidu AdMob splash onClose');
}).addEventListener('onClick', function(event) {
console.log('Baidu AdMob splash onClick');
});
Feeds联盟(Feeds)
cordova.BaiduAdMob.FeedsAd.url({
app: YOUR_APP_ID,
channel: YOUR_CHANNEL_ID
}).addEventListener('onSuccess', function(event) {
console.log('Baidu AdMob feeds onSuccess');
// Feeds联盟接入URL
alert(event.url);
}).addEventListener('onError', function(event) {
console.log('Baidu AdMob feeds onError');
});
FAQ
Empty
Support
Contribute
Please contribute! Look at the issues.
License
This project is licensed under MIT.