Я пытаюсь получить токен пользователя fcm и загрузить его в базу данных.
Я следовал этому уроку: https://www.youtube.com/watch?v=SOOjamH1bAA
Это моя функция:
async getToken() {
let token;
if(this.platform.is('android')) {
token = await this.firebaseNative.getToken();
}
if (this.platform.is('ios')) {
token = await this.firebaseNative.getToken();
await this.firebaseNative.grantPermission();
}
return this.saveTokenToDb(token);
}
import:
import { Injectable } from '@angular/core';
import { Firebase } from '@ionic-native/firebase/ngx';
import { Platform } from "ionic-angular";
import { AngularFireDatabase } from '@angular/fire/database';
import { Device } from '@ionic-native/device';
app.module:
imports: [
...
AngularFireModule.initializeApp(FIREBASE_CONFIG),
AngularFireDatabaseModule
],
bootstrap: [IonicApp],
entryComponents: [
...
],
providers: [
...
AngularFireDatabase,
Firebase,
Device,
FcmProvider
]
И когда я запускаю свое приложение, я получаю эту ошибку:
Uncaught (in promise): TypeError: Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"]) is not a function. (In 'Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"])(this, "getToken", {}, arguments)', 'Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"])' is an instance of Object)
getToken@http://10.0.0.23:8100/build/vendor.js:64573:123
http://10.0.0.23:8100/build/main.js:1109:74
step@http://10.0.0.23:8100/build/main.js:1072:27
http://10.0.0.23:8100/build/main.js:1047:75
t@http://10.0.0.23:8100/build/polyfills.js:3:21507
http://10.0.0.23:8100/build/main.js:1043:36
handleDb@http://10.0.0.23:8100/build/main.js:271:26
onSignIn@http://10.0.0.23:8100/build/main.js:254:26
callWithDebugContext@http://10.0.0.23:8100/build/vendor.js:15783:47
dispatchEvent@http://10.0.0.23:8100/build/vendor.js:10689:36
http://10.0.0.23:8100/build/vendor.js:39326:65
onInvokeTask@http://10.0.0.23:8100/build/vendor.js:5436:43
runTask@http://10.0.0.23:8100/build/polyfills.js:3:10844
invokeTask@http://10.0.0.23:8100/build/polyfills.js:3:16801
p@http://10.0.0.23:8100/build/polyfills.js:2:27654
v@http://10.0.0.23:8100/build/polyfills.js:2:27894