-
Notifications
You must be signed in to change notification settings - Fork 127
Cordova first steps
Marc Pascual edited this page Jun 11, 2020
·
10 revisions
title: Cordova-Phonegap first steps description: First steps url: /cordova-first-steps contributors:
- appfeel
- bitgenoma
- marcpascualsanchez
- miqmago
When working on a device, keep in mind the plugin will be available after the device is ready. Always wait for this event called 'deviceready'.
The plugin can be always be found inside the window object.
Keep in mind that the ids used in the example are for Android dev tests. If you do not replace them use the isTest option.
document.addEventListener('deviceready', this.onDeviceReady, false);
async function onDeviceReady() {
await admob.createBannerView({ bannerAdId: 'ca-app-pub-3940256099942544/6300978111' });
}
import { Component, OnInit } from '@angular/core';
import { Platform } from 'ionic-angular';
import { Admob } from '@ionic-native/admob';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
})
export class HomePage implements OnInit {
constructor(private admob: Admob, private platform: Platform) { }
async ngOnInit(): Promise<void> {
await this.platform.ready();
await this.admob.createBannerView({ bannerAdId: 'ca-app-pub-3940256099942544/6300978111' });
}
}
Angular is referring to Angular2 version and up, for AngularJS (Angular1) see this example