Created
September 21, 2016 13:05
-
-
Save bigmeech/a28f7ffe71c1e37dec67104d08fe4747 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
| I am trying to retrieve something from localstorage but would use that to decide what is served, | |
| so until that happens execution cannot continue. | |
| I feel I am doing something wrong as the getKey property of the LocalStorage retunrs a promise | |
| import { Component, ViewChild } from '@angular/core'; | |
| import { ionicBootstrap, Platform, Nav, LocalStorage , Storage } from 'ionic-angular'; | |
| import { StatusBar, Splashscreen, Push } from 'ionic-native'; | |
| import { HomePage } from './pages/home/home'; | |
| import { TutorialPage } from './pages/tutorial/tutorial' | |
| interface PageObj { | |
| title: string; | |
| component: any; | |
| icon: string; | |
| index?: number; | |
| } | |
| @Component({ | |
| templateUrl:'build/app.html' | |
| }) | |
| export class MyApp { | |
| @ViewChild(Nav) nav: Nav; | |
| rootPage: any = TutorialPage; | |
| local:any; | |
| pages : PageObj[] = [ | |
| { title: 'Home', component: HomePage, icon: 'contacts' }, | |
| { title: 'Top Promotions', component: HomePage, icon: 'person', index:1 }, | |
| { title: 'Search Campaigns', component: HomePage, icon: 'search', index:2 }, | |
| //{ title: 'Messages', component: HomePage, icon: 'email', index:3 }, | |
| { title: 'Favorites', component: HomePage, icon: 'bookmark', index:4 }, | |
| { title: 'Reviews/Comments', component: HomePage, icon: 'chatboxes', index:5 }, | |
| ]; | |
| loggedInPages: PageObj[] = [ | |
| { title: 'Account', component: HomePage, icon: 'person' }, | |
| { title: 'Logout', component: HomePage, icon: 'log-out' } | |
| ]; | |
| loggedOutPages: PageObj[] = [ | |
| { title: 'Login', component: HomePage, icon: 'log-in' }, | |
| { title: 'Signup', component: HomePage, icon: 'person-add' } | |
| ]; | |
| constructor(public platform: Platform) { | |
| platform.ready().then(() => { | |
| // Okay, so the platform is ready and our plugins are available. | |
| // Here you can do any higher level native things you might need. | |
| StatusBar.styleDefault(); | |
| this.local = new Storage(LocalStorage); | |
| this.local.get('user').then(function(user){ | |
| if(user != null) | |
| { | |
| console.log(user); | |
| } | |
| else{ | |
| } | |
| }); | |
| Splashscreen.hide(); | |
| var push = Push.init({ | |
| android: { | |
| senderID: "126468130105" | |
| }, | |
| ios: { | |
| alert: "true", | |
| badge: true, | |
| sound: 'false' | |
| }, | |
| windows: {} | |
| }); | |
| push.on('registration', (data) => { | |
| console.log(data.registrationId); | |
| alert(data.registrationId.toString()); | |
| }); | |
| push.on('notification', (data) => { | |
| console.log(data); | |
| alert("Hi, Am a push notification"); | |
| }); | |
| push.on('error', (e) => { | |
| console.log(e.message); | |
| }); | |
| }); | |
| } | |
| } | |
| ionicBootstrap(MyApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment