Last active
September 4, 2018 18:04
-
-
Save Sampath-Lokuge/c532167c544dd15b2d0d390bbdff4b27 to your computer and use it in GitHub Desktop.
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
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