代码之家  ›  专栏  ›  技术社区  ›  Deepika Wadhera

谷歌登录+FCM一起在一个离子2项目中

  •  1
  • Deepika Wadhera  · 技术社区  · 8 年前

    我正在使用Ionic2框架,我的应用程序需要谷歌登录和fcm才能接收通知。

    我首先使用Google plus本地插件集成了Google社交登录,它运行得非常好。然后,在添加fcm时,我收到以下错误:

    Found com.google.android.gms:play-services-location:11.+, but version 9.0.0 is needed for the google-services plugin.
    Found com.google.android.gms:play-services-auth:11.8.0, but version 9.0.0 is needed for the google-services plugin.
    Found com.google.android.gms:play-services-identity:11.8.0, but version 9.0.0 is needed for the google-services plugin.
    :processArmv7DebugGoogleServices
    FAILED
    

    由于版本冲突,我将其升级到9.0.0,fcm现在运行良好,但Google登录似乎已经停止工作。我没有收到任何错误。这个函数什么都没有。

    有谁能告诉我一种方法,把Google Login+FCM集成到一个io2项目中吗?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Anandh Sp    8 年前

    尝试在fcm插件目录下更改此文件

    /插件/cordova plugin fcm/src/android/FCMPlugin.gradle

    buildscript {
        repositories {
                jcenter()
                mavenLocal()
            }
        dependencies {
            classpath 'com.android.tools.build:gradle:+'
            classpath 'com.google.gms:google-services:3.0.0'
        }
    }
    // 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
    ext.postBuildExtras = {
        apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    }
    

    那么

    ionic cordova platform rm android
    ionic cordova platform add android
    

    然后更改此文件 /platforms/android/project.properties(使用11.4.2删除+文件)

    # This file is automatically generated by Android Tools.
    # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
    #
    # This file must be checked in Version Control Systems.
    #
    # To customize properties used by the Ant build system edit
    # "ant.properties", and override values to adapt the script to your
    # project structure.
    #
    # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
    #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
    # Project target.
    target=android-26
    android.library.reference.1=CordovaLib
    cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
    cordova.system.library.2=com.google.firebase:firebase-core:11.4.2
    cordova.system.library.3=com.google.firebase:firebase-messaging:11.4.2
    cordova.gradle.include.1=cordova-plugin-fcm/mobile-FCMPlugin.gradle
    cordova.system.library.4=com.google.android.gms:play-services-auth:11.4.2
    cordova.system.library.5=com.google.android.gms:play-services-identity:11.4.2
    cordova.system.library.6=com.android.support:support-v4:24.1.1+
    cordova.gradle.include.2=cordova-support-google-services/mobile-build.gradle
    cordova.gradle.include.3=twitter-connect-plugin/mobile-twitter.gradle
    cordova.system.library.7=com.squareup.okhttp3:okhttp:3+
    

    然后建造

    ionic cordova build android
    
    推荐文章