FCMPluging and GooglePlus conflict


#1

Hello,

I’m trying to use several plugins in Ionic2 Type Script Android application

Push Notification:

ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=mySenderId
npm install --save @ionic-native/push

GooglePlus for authentication:

cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myReversedClientId
npm install --save @ionic-native/google-plus

and FCM to send Push Notification with FCMPlugin to specific device:

ionic cordova plugin add cordova-plugin-fcm
npm install --save @ionic-native/fcm

before I add the last installations fcm my project.properties was:

target=android-26
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:25.+
cordova.system.library.3=com.android.support:appcompat-v7:25.+
cordova.system.library.4=com.android.support:support-v13:26.+
cordova.system.library.5=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.6=com.google.firebase:firebase-messaging:11.6.2
cordova.gradle.include.1=phonegap-plugin-push/myapp-push.gradle
cordova.system.library.7=com.google.android.gms:play-services-auth:11.6.2
cordova.system.library.8=com.google.android.gms:play-services-identity:11.6.2

and config.xml:

    ...
    <plugin name="phonegap-plugin-push" spec="^2.1.3">
        <variable name="SENDER_ID" value=" mySenderId " />
        <variable name="FCM_VERSION" value="11.6.2" />
    </plugin>
    <plugin name="cordova-plugin-googleplus" spec="^5.3.0">
        <variable name="REVERSED_CLIENT_ID" value=" myReversedClientId " />
    </plugin>
    <engine name="android" spec="7.0.0" />
</widget>

after installation of fcm it is:

target=android-26
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:25.+
cordova.system.library.3=com.android.support:appcompat-v7:25.+
cordova.system.library.4=com.android.support:support-v13:26.+
cordova.system.library.5=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.6=com.google.firebase:firebase-messaging:11.6.2
cordova.gradle.include.1=phonegap-plugin-push/myapp-push.gradle
cordova.system.library.7=com.google.android.gms:play-services-auth:11.6.2
cordova.system.library.8=com.google.android.gms:play-services-identity:11.6.2
cordova.system.library.9=com.google.firebase:firebase-core:+
cordova.system.library.10=com.google.firebase:firebase-messaging:+
cordova.gradle.include.2=cordova-plugin-fcm/myapp-FCMPlugin.gradle

and config.xml:

...
    <plugin name="phonegap-plugin-push" spec="^2.1.3">
        <variable name="SENDER_ID" value=" mySenderId " />
        <variable name="FCM_VERSION" value="11.6.2" />
    </plugin>
    <plugin name="cordova-plugin-googleplus" spec="^5.3.0">
        <variable name="REVERSED_CLIENT_ID" value=" myReversedClientId " />
    </plugin>
    <plugin name="cordova-plugin-fcm" spec="^2.1.2" />
    <engine name="android" spec="7.0.0" />
</widget>

when I start to build the project, I get a several errors, which was solved as follows:

ERROR 1 (Invalid data, chunk must be a string or buffer, not object):

in plugins/cordova-plugin-fcm/scripts/fcm_config_files_process.js :

change:

var strings = fs.readFileSync("platforms/android/res/values/strings.xml").toString();

to:

var strings = fs.readFileSync("platforms/android/app/src/main/res/values/strings.xml").toString();

change:

fs.writeFileSync("platforms/android/res/values/strings.xml", strings);

to:

fs.writeFileSync("platforms/android/app/src/main/res/values/strings.xml", strings);

ERROR 2 (Execution failed for task ‘:app:processDebugGoogleServices’.):

in plugins/cordova-plugin-fcm/src/android/FCMPlugin.gradle and platforms/android/cordova-plugin-fcm/myapp-FCMPlugin.gradle :

buildscript {
	repositories {
            jcenter()
			mavenLocal()
        }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

with change this:

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

to this:

ext.postBuildExtras = {
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

After this edits ionic cordova build builds android application without errors, but GooglePlus button with authentication and getting of user data stops to work:

googleRegistration() {
    this.googlePlus.login({
      'webClientId': 'myClientId',
      'offLine': true
    })
      .then(res => {
        firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken))
          .then(suc => {
            alert("LOGIN SUCCESSFUL")
          }).catch(ns => {
            "LOGIN NOT SUCCESSFUL"
          })

        this.displayName = res.displayName;
        this.email = res.email;
        this.userId = res.userId;
        ...

      })
      .catch(err => console.error(err));
  }

Not sure how to figure out, advice would be very helpful


Run function in background mode with time interval to execute http request and get alert popup