Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { SmsVerificationService } from 'src/app/services/SMS/sms-verification.service';
- import { Component } from '@angular/core';
- import { Platform } from '@ionic/angular';
- import { SplashScreen } from '@ionic-native/splash-screen/ngx';
- import { StatusBar } from '@ionic-native/status-bar/ngx';
- import { FCM } from '@ionic-native/fcm/ngx';
- import { Plugins, Capacitor } from '@capacitor/core';
- import { Router } from '@angular/router';
- import { Storage } from '@ionic/storage';
- @Component({
- selector: 'app-root',
- templateUrl: 'app.component.html'
- })
- export class AppComponent {
- constructor(
- private platform: Platform,
- private splashScreen: SplashScreen,
- private statusBar: StatusBar,
- private fcm: FCM,
- private route: Router,
- private storage: Storage
- ) {
- this.initializeApp();
- }
- initializeApp() {
- this.platform.ready().then(() => {
- this.fcm.getToken().then(token => {
- console.log(' token is ', token);
- });
- this.fcm.onTokenRefresh().subscribe(token => {
- console.log('on token refresh ', token);
- });
- this.fcm.onNotification().subscribe(data => {
- console.log(data);
- if (data.wasTapped) {
- console.log('Received in background');
- // this.router.navigate([data.landing_page, data.price]);
- } else {
- console.log('Received in foreground');
- // this.router.navigate([data.landing_page, data.price]);
- }
- });
- this.storage.get('isLogined').then(data => {
- if (data)
- this.route.navigateByUrl('/main-tab');
- })
- this.statusBar.styleDefault();
- this.splashScreen.hide();
- if (Capacitor.isPluginAvailable('SplashScreen')) {
- Plugins.SplashScreen.hide();
- }
- });
- }
- }
- this.storage.get('isLogined').then(data => {
- if (data)
- this.route.navigateByUrl('/main-tab');
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement