Я хочу реализовать push-уведомления с помощью службы Firebase Cloud Messenger. Я добавил:
ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated
npm install @ionic-native/fcm
В app.component.ts
:
import { FCM } from '@ionic-native/fcm/ngx';
// ...
constructor(private fcm: FCM)
// ...
this.fcm.getToken().then(token => {
console.log('Token :', token);
});
Это вызывает у меня ошибку на рабочем столе, потому что Cordova недоступна, все нормально.
Но когда я хочу протестировать на Android, как обычно, я делаю:
ionic cordova run android --device
И это дает мне ошибку:
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\<username>\Documents\weezchat_ionic\platforms\android\cordova-plugin-fcm-with-dependecy-updated\billingtests-FCMPlugin.gradle' line: 21
* What went wrong:
A problem occurred evaluating script.
> Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
> For input string: "+"
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
[ERROR] An error occurred while running subprocess cordova.
cordova run android --device exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Я работаю с:
Ionic:
ionic (Ionic CLI) : 4.12.0 (C:\Users\username\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.1.1
@angular-devkit/build-angular : 0.13.6
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.3.6
@ionic/angular-toolkit : 1.4.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 8 other plugins)
System:
Android SDK Tools : 26.1.1 (C:\Users\username\AppData\Local\Android\Sdk)
NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10
Это содержимое \ платформы \ android \ cordova-plugin-fcm-with-dependency-updated \ billingtests-FCMPlugin.gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.google.gms:google-services:3.1.+'
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.google.firebase:firebase-core:10.+'
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin