Skip to content

Instantly share code, notes, and snippets.

@Sampath-Lokuge
Last active September 4, 2018 18:04
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Sampath-Lokuge/c532167c544dd15b2d0d390bbdff4b27 to your computer and use it in GitHub Desktop.
Ionic Native plugin: http://ionicframework.com/docs/native/firebase/
base-page.ts
-------------
import { Firebase } from "@ionic-native/firebase";
export abstract class BasePage {
constructor(public firebase: Firebase) { }
//collect Analytics
protected collectAnalytics(contentType: string, itemId: string): void {
this.firebase.logEvent("select_content", { content_type: contentType, item_id: itemId })
.then((success) => console.log(`success`))
.catch(error => console.error('Error', error));
}
}
my-page.ts
----------
export class MyPage extends BasePage {
constructor(private platform: Platform, public firebase: Firebase) {
super(firebase);
}
ionViewDidLoad() {
this.platform.ready().then(() => {
super.collectAnalytics('add page view', 'survey');//collect Analytics
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment