|
1 |
| -import Vue from 'nativescript-vue' |
2 |
| -import Home from './components/Home.vue' |
| 1 | +import Vue from 'nativescript-vue'; |
| 2 | +import Home from './components/Home.vue'; |
3 | 3 |
|
4 | 4 | declare let __DEV__: boolean;
|
5 | 5 |
|
6 | 6 | // Prints Vue logs when --env.production is *NOT* set while building
|
7 |
| -Vue.config.silent = !__DEV__ |
| 7 | +Vue.config.silent = !__DEV__; |
| 8 | + |
| 9 | +import { firebase } from '@nativescript/firebase-core'; |
| 10 | +import '@nativescript/firebase-analytics'; |
| 11 | +import '@nativescript/firebase-auth'; |
| 12 | +import '@nativescript/firebase-crashlytics'; |
| 13 | +import '@nativescript/firebase-database'; |
| 14 | +import '@nativescript/firebase-dynamic-links'; |
| 15 | +import '@nativescript/firebase-firestore'; |
| 16 | +import '@nativescript/firebase-functions'; |
| 17 | +import '@nativescript/firebase-in-app-messaging'; |
| 18 | +import '@nativescript/firebase-installations'; |
| 19 | +import '@nativescript/firebase-messaging'; |
| 20 | +import '@nativescript/firebase-performance'; |
| 21 | +import '@nativescript/firebase-remote-config'; |
| 22 | +import '@nativescript/firebase-storage'; |
| 23 | + |
| 24 | +import { Admob } from '@nativescript/firebase-admob'; |
| 25 | + |
| 26 | +import { AppCheck } from '@nativescript/firebase-app-check-debug'; |
| 27 | +import { Application } from '@nativescript/core'; |
| 28 | + |
| 29 | +AppCheck.setProviderFactory(); |
| 30 | +declare const TNSFirebaseCore; |
| 31 | +firebase() |
| 32 | + .initializeApp() |
| 33 | + .then((app) => { |
| 34 | + firebase().appCheck().activate(true); |
| 35 | + firebase().crashlytics().setCrashlyticsCollectionEnabled(true); |
| 36 | + }); |
| 37 | + |
| 38 | +Admob.init(); |
| 39 | + |
| 40 | +const dynamicLinks = firebase().dynamicLinks(); |
| 41 | + |
| 42 | +dynamicLinks.onLink((link) => { |
| 43 | + console.log('onLink', link); |
| 44 | +}); |
| 45 | + |
| 46 | +const messaging = firebase().messaging(); |
| 47 | + |
| 48 | +Application.on('launch', (args) => { |
| 49 | + messaging.onMessage((message) => { |
| 50 | + console.log('Firebase onMessage', message); |
| 51 | + }); |
| 52 | + |
| 53 | + messaging.onNotificationTap((message) => { |
| 54 | + console.log('Firebase onNotificationTap', message); |
| 55 | + }); |
| 56 | + |
| 57 | + messaging.onToken((token) => { |
| 58 | + console.log('Firebase onToken', token); |
| 59 | + }); |
| 60 | +}); |
| 61 | + |
| 62 | +if (global.isIOS) { |
| 63 | + messaging |
| 64 | + .requestPermission() |
| 65 | + .then(() => { |
| 66 | + console.log('requestPermission', 'done'); |
| 67 | + messaging.registerDeviceForRemoteMessages().catch((e) => { |
| 68 | + console.error('registerDeviceForRemoteMessages', e); |
| 69 | + }); |
| 70 | + }) |
| 71 | + .catch((e) => { |
| 72 | + console.error('requestPermission', e); |
| 73 | + }); |
| 74 | +} |
8 | 75 |
|
9 | 76 | new Vue({
|
10 |
| - render: (h) => h('frame', [h(Home)]), |
11 |
| -}).$start() |
| 77 | + render: (h) => h('frame', [h(Home)]), |
| 78 | + mounted() { |
| 79 | + firebase() |
| 80 | + .messaging() |
| 81 | + .requestPermission() |
| 82 | + .then(() => { |
| 83 | + console.log('requestPermission', 'done'); |
| 84 | + firebase() |
| 85 | + .messaging() |
| 86 | + .registerDeviceForRemoteMessages() |
| 87 | + .catch((e) => { |
| 88 | + console.error('registerDeviceForRemoteMessages', e); |
| 89 | + }); |
| 90 | + }) |
| 91 | + .catch((e) => { |
| 92 | + console.error('requestPermission', e); |
| 93 | + }); |
| 94 | + }, |
| 95 | +}).$start(); |
0 commit comments