Baidu Advertising Cordova/phonegap Plugin use tutorial

Source: Internet
Author: User

Baidu Alliance Cordova/phonegap Plug-in, is a convenient HTML5 development of the use of Baidu advertising plug-ins, can be very convenient in HTML5 mixed applications such as Cordova,xdk,appcan,webx5,jqmobile, Sencha touch, Ionic in the Baidu SSP Alliance ads, iOS and Android apps are supported, the code is exactly the same without modification.

Use the following procedure

installation Cordova/phonegap Baidu Advertising Plugin

I started with the Cordova command line installed directly from GitHub remotely, and entered on the command line

Cordova Plugin Add Https://github.com/baidumobad/baidu-ssp-phonegap-plugin.git

But my network is not good installation failed, the following error occurred

I downloaded the plugin to local (official https://github.com/baidumobad/baidu-ssp-phonegap-plugin), and after extracting it, I installed it via local input command.

Cordova Plugin Add D:\baidu-ssp-phonegap-plugin

After the execution, there is no error, the project under the plugins directory more than a directory Com.baidu.cordova.plugin.BaiduAdPlugin, installation success

in the Cordova/phonegap application of the display of Baidu advertising interstitial ads

CORDOVA/PHONEGAP application in the display of Baidu ads full-screen ads, than banner to a slightly more complex point, need to first cache loading full-screen ads, and so on after loading and then showinterstitial to display ads, Direct showinterstitial will not appear in advertising. I display ads immediately after full-screen ads are loaded and, of course, according to their own application characteristics, can be changed to the end of the game show. My JS code is as follows. AppID is the app Id,fullid is a full screen ad bit.

function oninterstitialreceive (message) {

Baiduad.showinterstitial ();//Display ads when loading is complete

}

Document.addeventlistener (' oninterstitialreceive ', oninterstitialreceive, false);//monitor AD Load Success Event

Baiduad.initinterstitial ("AppID", "fullid");//Create AD

Baiduad.cacheinterstitial ()//Create a full screen and load the ad

Cordova/phonegap app to insert banner ads for Baidu Mobile ads

In the HTML of the JS section to add the following JS code, where AppID and Bannerid is in the Baidu mobile SSP background application to the parameters, which AppID is Baidu Advertising (http://ssp.baidu.com) inside the application Id,banner The ID is the banner code bit; baiduad.ad_position. Bottom_center is the ad location, which means the bottom center of the app. There are other relative positions, specifically can be seen baiduad.ad_position. Constant inside the bottom. You can also use absolute positioning, examples of plugins are included. For convenience I still use the relative positioning.

Baiduad.initbanner ("AppID", "Bannerid");//Initialize banner ad

Baiduad.showbanner (baiduad.ad_position. Bottom_center);//Display the ad in a relative position, the value of the specific relative position ad_position

Remove Baidu Ads

Full screen ads do not require code removal, and the user clicks the Close button to hide the removal.

Banner ads can be removed by calling Baiduad.hidebanner ().

Baidu Mobile Advertising Cordova/phonegap additional attention points for plugins

1.Init functions only need to be called once, directly behind the banner show, full screen direct cache.

2. Need to re-cache after full screen display

3. If you do not display full screen ads in full-screen receive completion events, you need to call Isinterstitialready before displaying to determine if the ad is loaded.

4. More usage can be seen in the plugin directory of the example directory example

5. If there is a problem, you can join the Exchange group 475496285

Baidu Advertising Cordova/phonegap Plugin use tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.