Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Component, ViewChild} from '@angular/core';
- import {Platform, MenuController, ToastController, Events, Nav} from 'ionic-angular';
- import { StatusBar } from '@ionic-native/status-bar';
- import { SplashScreen } from '@ionic-native/splash-screen';
- import { GoogleAnalytics } from '@ionic-native/google-analytics';
- import { Storage } from '@ionic/storage';
- import { ImageLoaderConfig } from 'ionic-image-loader';
- import { Deeplinks } from "@ionic-native/deeplinks";
- // import pages
- import {WelcomeIntroPage} from '../pages/welcome/intro/intro-welcome';
- import {LoginPage} from '../pages/login/login-page';
- import {ExperienceShowPage} from "../pages/experience/show/show-experience";
- import {UserProfilePage} from "../pages/user/profile/profile-user";
- @Component({
- templateUrl: 'app.component.html',
- providers : [Deeplinks]
- })
- export class MyCApp {
- public rootPage:any;
- public nav:any;
- constructor(public platform:Platform,
- public storage: Storage,
- public events: Events,
- public menuCtrl: MenuController,
- public toastCtrl: ToastController,
- private splashScreen: SplashScreen,
- private statusBar: StatusBar,
- private ga: GoogleAnalytics,
- private imageLoaderConfig: ImageLoaderConfig,
- private deeplinks : Deeplinks)
- {
- // show splash screen
- this.splashScreen.show();
- //Image loader global config
- //See https://github.com/zyra/ionic-image-loader#global-configuration
- this.imageLoaderConfig.setBackgroundSize('cover');
- this.imageLoaderConfig.setFallbackUrl('assets/icon/no-pic.png');
- this.imageLoaderConfig.setMaximumCacheSize(20 * 1024 * 1024); // set max size to 20MB
- this.imageLoaderConfig.setMaximumCacheAge(30 * 24 * 60 * 60 * 1000); // 30 days
- this.imageLoaderConfig.enableSpinner(true);
- //this.imageLoaderConfig.enableDebugMode();
- 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.
- this.statusBar.styleDefault();
- //this.statusBar.overlaysWebView(true);
- this.splashScreen.hide();
- console.log('after hide'); //This shows in the console
- //Start Google Analytics
- this.ga.startTrackerWithId('UA-XXXXXX-2').then(() => {
- console.log('Google analytics ready');
- }).catch(e => console.log('Error starting GoogleAnalytics', e));
- //Check if we need to display the login screen or tutorial
- this.storage.get('welcome_intro').then((welcome_intro) => {
- if (! welcome_intro) {
- this.rootPage = WelcomeIntroPage;
- this.storage.set('welcome_intro', true);
- } else {
- this.rootPage = LoginPage;
- this.ga.trackView('Login page');
- }
- });
- });
- }
- // Deeplinks navigate to the pages
- ngAfterViewInit() {
- this.platform.ready().then(() => {
- // Convenience to route with a given nav
- this.deeplinks.routeWithNavController(this.nav, {
- '/experience/:experience_id': ExperienceShowPage,
- '/talent/:user_id': UserProfilePage ,
- }).subscribe((match) => {
- console.log('Successfully routed: '+ JSON.stringify(match));
- }, (nomatch) => {
- console.log('Unmatched Route: '+ nomatch);
- });
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement