Run your PhoneGap build application with AdMob

Source: Internet
Author: User
Tags configuration settings admob

With the recent PhoneGap build changes, we can now use all the plugins listed in Plugins.cordova.io, as well as plugins on the https://github.com/website. This means that we have now entered AdMob plugins, which will allow us to integrate AdMob with the PhoneGap build application.

AdMob will allow ads to appear on users ' mobile apps, show them and earn revenue – how AdSense works like a website. This is a very common mobile app running strategy, especially for games. With enough users, a significant amount of revenue can be generated. It also works well with app purchases, offers to remove ads from apps, and if users want a free app ad experience – This is also a very common running strategy.

Comparison of AdMob and IAD in phonegap applications
AdMob is Google's mobile advertising solution, and IAD is the solution to Apple's mobile advertising program. Both can be used, but which one should we choose? What's the difference?

In fact, both of these can be used, and if no ads are available you can use one as a fallback. However, developers have reported that they are receiving higher fill rates and revenue clicks on the AdMob platform.

Stack overflow user Luc Wollants, who provides advice on this topic, points out: "The iad has a filling rate of around 30%, and AdMob's fill rate is around 95%." ”

The best approach is to always use both, and there are some strategies for how to deal with them, but in this tutorial we will consider setting up AdMob.

What is the difference between AD and banner ads?
There are two types of ads that you can create admob, namely:
• In-stream ads and banner ads
In-stream ads are ads that pop up and occupy the entire screen (annoying!). But effective). As an example of a mobile game, I create an in-stream ad at the end of each player's game – you have to make sure that most of the time you don't show a slot in the user's game!

Banner ads are visible at any time (unless you hide them), and these banners are usually placed in small rectangles at the top or bottom of the application.

Set up your AdMob account and ads
You'll need to create a Google AdMob account before you start, and your AdMob account will need a Google account, as well as an AdSense and AdWords account. If you do not have these accounts you can create them during admob (you do not need to register separately beforehand).

You will need to create the type of ad you want to use with AdMob's control panel. If you want to use both interstitial and banner ads, then you will need to create and configure these separately.
• Tap "Run new app" and create app
• Create a slot and a banner ad by clicking on "new ad unit"

Add ads to your app
First, you need to provide the functionality in the application, including your CONFIG. Plugins in the XML file:
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
There are a few options, but we will use this plugin.

1. Once the device is ready to configure AdMob
You need to add the following code to your application, and the event is launched when the device is ready:
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
Make sure to replace the above ID from your own AdMob control panel.

2. Prepare an in-stream ad
If you want to use an in-stream ad, you have to cache it beforehand, and you can use the following code:
<uses-permission android:name= "Android.permission.RECORD_AUDIO"/>
<uses-feature android:name= "Android.hardware.microphone" android:required= "false"/>

3. Display banner ads
Display Banner ad is a simple line, the following content can be implemented:
<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
The second parameter needs to be in the location of your banner ad, in which case we place the ad at the bottom of the app.

You can also change the second parameter of AdMob. Position.top_app placed at the top of your app, you can use the following code to place banner ads:
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

4. Show in-stream ads
It's also easy to trigger interstitial ads:
Admob.isinterstitialready (function (isReady) {
if (IsReady) {
Admob.showinterstitial ();
}
});

Further this tutorial covers the basics of this AdMob plugin and implements a very common configuration in mobile app ads-a constant banner ad view as well as pop-up ads at specific times.

There are options to specify the configuration settings for ads (for example, to set a test flag or set keywords), but the most noticeable is that the plugin also provides a series of events. These events can be used to modify the behavior of your ad based on whether the ad is available and what your users are doing. The available events are:
Onadmobbannerdismiss
onadmobbannerfailedreceive
onadmobbannerleaveapplication
onadmobbannerpresent
onadmobbannerreceive
Onadmobinterstitialdismiss
onadmobinterstitialfailedreceive
onadmobinterstitialleaveapplication
onadmobinterstitialpresent
onadmobinterstitialreceive

If you want to go deep into the AdMob plugin, you can read the article above https://github.com/.

Run your PhoneGap build application with AdMob

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.