Created
October 28, 2018 06:31
-
-
Save eladcandroid/75bb38967c0b74346b2998b599ef2e09 to your computer and use it in GitHub Desktop.
adMob.js for cordova-plugin-admob-free
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let adMob = null; | |
export function initAd() { | |
adMob = window.plugins.AdMob || window.AdMob; | |
if (/(android)/i.test(navigator.userAgent) && adMob) { | |
adMob.banner.config({ | |
id: "ca-app-pub-8953910389003952/3660976168", | |
autoShow: false, | |
isTesting: process.env.NODE_ENV === "production" ? false : true | |
}); | |
adMob.banner.prepare(); | |
adMob.interstitial.config({ | |
id: "ca-app-pub-8953910389003952/2792136689", | |
autoShow: false, | |
isTesting: process.env.NODE_ENV === "production" ? false : true | |
}); | |
adMob.interstitial.prepare(); | |
} | |
} | |
export function showInterstitial() { | |
if (adMob) adMob.interstitial.show(); | |
} | |
export function showAd() { | |
if (adMob) adMob.banner.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: (VueJS)
In main.js for example:
import { initAd, showAd } from "./adMob";
....
....