首先,进入中控易动平台(www.yd-mobile.cn),创建一个应用,创建完成进入应用,然后添加AdView插件AdView插件:集成AdView展示广告功能,支持开屏、横幅、插屏、原生、视频等广告样式注意:·插件的所有接口在 deviceready 事件后生效;使用插件需配置:SDKKEY(参考AdView插件配置);·展示开屏、横幅、插屏、原生、视频等广告样式需要在AdView平台申请广告位(参考AdView插件配置;·开屏广告默认展示;·视频广告暂时只支持激励视频样式;·当前iOS使用AdViewSDK_iOS版本是4.0.6;·当前Android使用AdViewSDK_Android版本是4.0.9;·广告接口调用限制30s一次;1展示横幅广告navigator.adview.showBannerAd(success, error,options)支持平台:·Android·iOS参数说明
// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居上显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); });}
设置广告居上向下偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居上向下偏移30显示 navigator.adview.showBannerAd( function(success) { console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'x':30,'type':'top'});}
设置广告居中显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'type':'center'});}
设置广告居中向下偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中向下偏移30显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'x':30,'type':'center'});}
设置广告居中向上偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中向上偏移30显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'y':30,'type':'center'});}
设置广告居下显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居下显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'type':'bottom'});}
设置广告居下向上偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居下向上偏移30显示 navigator.adview.showBannerAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'y':30,'type':'bottom'});}
2展示插屏广告navigator.adview.showInterteristalAd(success, error)支持平台:·Android·iOS参数说明// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ navigator.adview.showInterteristalAd(function(success) { console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); });}
3展示原生广告navigator.adview.showNativeAd(success, error,options)支持平台:·Android·iOS参数说明// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居上显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj'});}
设置广告居上向下偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居上向下偏移30显示 navigator.adview.showNativeAd( function(success) { console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','x':30,'type':'top'});}
设置广告居中显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','type':'center'});}
设置广告居中向下偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中向下偏移30显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','x':30,'type':'center'});}
设置广告居中向上偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居中向上偏移30显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','y':30,'type':'center'});}
设置广告居下显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居下显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','type':'bottom'});}
设置广告居下向上偏移30显示// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ //设置广告居下向上偏移30显示 navigator.adview.showNativeAd( function (success){ console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSIDs38o5ybf6agj','y':30,'type':'bottom'});}
4展示视频广告navigator.adview.showVideoAd(success, error,options)支持平台:·Android·iOS参数说明// 监听’deviceready‘事件document.addEventListener('deviceready', onDeviceReady, false)function onDeviceReady(){ navigator.adview.showVideoAd(function (success) { console.log(JSON.stringify(success)); },function (error){ alert(JSON.stringify(error)); },{'positionID':'POSID74pjtjpxo516'});}
以上就是使用AdView插件的全部教程了,快去试试吧(图片来源网络,侵删)
0 评论