百度ssp移動聯盟phonegap插件使用教程html
百度聯盟phonegap(cordova)插件,能很方便的在html5 hybrid應用(如cordova,xdk,appcan,webx5,jqmobile、sencha touch,ionic)中接入百度ssp聯盟廣告,支持ios和android平臺。
基於phonegap 3.4 或 cordova 3.5編譯html5
怎麼在html5應用中加入百度ssp移動聯盟廣告呢?能夠使用cordova命令行遠程或者本地方式安裝本百度移動廣告插件android
在命令行中輸入ios
cordova plugin add https://github.com/baidumobad/baidu-ssp-phonegap-plugin.gitgit
或者把插件下載到本地解壓後輸入命令 github
cordova plugin add c:\baidu-ssp-phonegap-pluginweb
在phonegap 類的html5應用中展現百度移動廣告橫幅類型廣告app
測試前把appID和bannerID替換爲你在百度ssp申請到的真實的參數ionic
baiduAd.initBanner("appID", "bannerID");//初始化banner廣告ide
baiduAd.showBanner(8);//用相對位置的方式展現廣告,具體的相對位置的值AD_POSITION中
在phonegap類型的html5應用中展現百度ssp移動聯盟插屏廣告:
在cordova應用中展現百度mob全屏插屏廣告
function onInterstitialReceive(message) {
baiduAd.showInterstitial();//加載完成後展現廣告
}
document.addEventListener('onInterstitialReceive', onInterstitialReceive, false);//監聽廣告加載成功事件
baiduAd.initInterstitial("appID", "fullID");//建立廣告
baiduAd.cacheInterstitial();//建立全屏完成後加載廣告
百度移動聯盟ssp廣告事件的處理
監聽處理廣告中的事件,例如監聽廣告接收成功事件 例子參考上面展現全屏廣告,事件類型定義在AdEvent中
更多接口
經過絕對定位的方式展現banner廣告
showBannerAbsolute(x,y)
隱藏banner廣告
hideBanner()
判斷全屏廣告是否已經加載完成
isInterstitialReady( successCallback, failureCallback)
接口的完整使用方式參考demo下代碼
百度ssp移動廣告phonegap插件官方網址:https://github.com/baidumobad/baidu-ssp-phonegap-plugin
百度ssp移動廣告官方網站http://ssp.baidu.com
phonegap app開發者交流羣 475496285