Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. import { SmsVerificationService } from 'src/app/services/SMS/sms-verification.service';
  2. import { Component } from '@angular/core';
  3. import { Platform } from '@ionic/angular';
  4. import { SplashScreen } from '@ionic-native/splash-screen/ngx';
  5. import { StatusBar } from '@ionic-native/status-bar/ngx';
  6. import { FCM } from '@ionic-native/fcm/ngx';
  7.  
  8.  
  9. import { Plugins, Capacitor } from '@capacitor/core';
  10. import { Router } from '@angular/router';
  11. import { Storage } from '@ionic/storage';
  12. @Component({
  13. selector: 'app-root',
  14. templateUrl: 'app.component.html'
  15. })
  16. export class AppComponent {
  17. constructor(
  18. private platform: Platform,
  19. private splashScreen: SplashScreen,
  20. private statusBar: StatusBar,
  21. private fcm: FCM,
  22. private route: Router,
  23. private storage: Storage
  24.  
  25. ) {
  26.  
  27.  
  28.  
  29. this.initializeApp();
  30. }
  31.  
  32. initializeApp() {
  33.  
  34. this.platform.ready().then(() => {
  35. this.fcm.getToken().then(token => {
  36. console.log(' token is ', token);
  37. });
  38. this.fcm.onTokenRefresh().subscribe(token => {
  39. console.log('on token refresh ', token);
  40. });
  41. this.fcm.onNotification().subscribe(data => {
  42. console.log(data);
  43. if (data.wasTapped) {
  44. console.log('Received in background');
  45. // this.router.navigate([data.landing_page, data.price]);
  46. } else {
  47. console.log('Received in foreground');
  48. // this.router.navigate([data.landing_page, data.price]);
  49. }
  50.  
  51. });
  52. this.storage.get('isLogined').then(data => {
  53. if (data)
  54. this.route.navigateByUrl('/main-tab');
  55. })
  56. this.statusBar.styleDefault();
  57. this.splashScreen.hide();
  58. if (Capacitor.isPluginAvailable('SplashScreen')) {
  59. Plugins.SplashScreen.hide();
  60. }
  61. });
  62. }
  63. }
  64.  
  65. this.storage.get('isLogined').then(data => {
  66. if (data)
  67. this.route.navigateByUrl('/main-tab');
  68. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement