【问题标题】:Firebase Messaging resolve Dependencies Error IonicFirebase 消息传递解决依赖关系错误离子
【发布时间】:2017-08-17 11:14:18
【问题描述】:

尝试在 Ionic 3 中使用 Firebase 云消息传递安装推送通知后,我收到此错误。 我还没有下载cordova FCM插件,因为根据我看过的教程,它不应该是必需的。

配置根项目“android”时出现问题。

无法解析配置“:_debugApkCopy”的所有依赖项。 找不到 com.google.firebase:firebase-messaging:11.0.1。 要求: 项目 : 找不到 com.google.firebase:firebase-core:11.0.1。 要求: 项目:

我已经尝试了https://firebase.google.com/docs/android/setup 中的所有步骤,并更新了 Google Repistory 和服务,如下所示: ![最新安装的安卓系统]http://i.imgur.com/vo1GcHP.png

构建.gradle

    apply plugin: 'com.android.application'

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}........
    dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.android.support:support-v13:25.1.0"
    compile "me.leolin:ShortcutBadger:1.1.17@aar"
    compile "com.google.firebase:firebase-messaging:11.0.1"
    // SUB-PROJECT DEPENDENCIES END
}.......
    if (hasProperty('postBuildExtras')) {
    postBuildExtras()
}
apply plugin: 'com.google.gms.google-services'

我认为此错误可能是由于安装的 Firebase 版本与项目所需的版本不同。根据该网站,11.2.0 版本已经发布,而我的项目需要 11.0.1。同样,我不知道应该在 build.gradle 文件中声明哪个版本的 google-services。请帮忙!

【问题讨论】:

  • 我遇到了同样的问题,我切换到 firebase 插件,它对我有用,请参阅 ionicframework.com/docs/native/firebase
  • @mohamadrabee 这就是我的想法,也许是唯一的选择。我想我会试试的。谢谢!

标签: android firebase ionic-framework firebase-cloud-messaging ionic3


【解决方案1】:

我们正在使用 FCM 插件,它运行良好。我们也想为浏览器构建添加推送通知,这需要使用 npm firebase package 以及:

import { FCM } from '@ionic-native/fcm';
import * as firebase from 'firebase/app';
import 'firebase/messaging';

@Injectable()
export class NotificationService {

  messaging: firebase.messaging.Messaging;

  constructor(
    private fcm: FCM,
    private platform: Platform,
  ) {

    if (platform.is('cordova') {
      // set up with fcm
    } else if (this.messaging.isSupported()) {
      // set up with firebase
    }

  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-20
    • 2016-11-11
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多