0
votes

I'm getting this error after trying to install Push Notifications with Firebase Cloud Messaging in Ionic 3. I haven't downloaded the cordova FCM plugin because according to a tutorial I watched, it shouldn't be necessary.

A problem occurred configuring root project 'android'.

Could not resolve all dependencies for configuration ':_debugApkCopy'. Could not find com.google.firebase:firebase-messaging:11.0.1. Required by: project : Could not find com.google.firebase:firebase-core:11.0.1. Required by: project :

I have tried all the steps in https://firebase.google.com/docs/android/setup and have updated Google Repistory and services as seen here: ![Latest Android Stuff Installed]http://i.imgur.com/vo1GcHP.png

Build.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'

I was thinking that this error could possibly be due to the version of Firebase installed versus what the project requires. According to the website, the version 11.2.0 is out whereas my project requires 11.0.1. Similarly, I don't know which version of google-services I should be declaring in my build.gradle file. Please help!

1
I had the same issue, I switch to firebase plugin and its work for me, see ionicframework.com/docs/native/firebase - mohamad rabee
@mohamadrabee That's what I was thinking perhaps would be the only option. I suppose I'll try it. Thanks ! - user7722867

1 Answers

0
votes

We're using the FCM plugin and it works quite well. We wanted to add push notification for the browser build too which required using the npm firebase package as well like:

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
    }

  }