Firebase云消息传递(FCM)无法在kitkat(4.4)下面的Android版本上运行

问题描述 投票:2回答:2

我根据文档实现了FCM,它完全适用于Android版本4.4(Kitkat)及以上版本,而不是4.3(Jelly Bean)及以下版本。根据FCM文档,它说所需的最低版本是4.0,我有游戏服务。 FCM正在生成刷新令牌,当我使用它从我的服务器或FCM控制台发送消息时,它无法正常工作。以下是FCM的Manifest条目。

Firebase documentation

     <service android:name=".service.RMFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
    <service android:name=".service.RMFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

任何建议表示赞赏。谢谢。

android firebase-cloud-messaging android-4.2-jelly-bean android-4.3-jelly-bean android-4.1-jelly-bean
2个回答
0
投票

我也有同样的问题,我更新了播放服务并更新了以下依赖项。它对我有用。

app.gradle

    compile 'com.google.firebase:firebase-messaging:12.0.1'
    compile 'com.google.android.gms:play-services-maps:12.0.1'

project.gradle

    classpath 'com.google.gms:google-services:3.2.0'

0
投票

使用最新的google-services插件。

在顶级build.gradle中进行更改

buildscript {
// ...
dependencies {
  // ...
  // Add the following line:
  classpath 'com.google.gms:google-services:4.2.0'  // Google Services plugin
}

}

allprojects {
// ...
repositories {
  // Check that you have the following line (if not, add it):
  google()  // Google's Maven repository
  // ...
}

}

在模块级别build.gradle文件中进行更改

 // Add the following line to the bottom of the file:
 apply plugin: 'com.google.gms:google-services'  // Google Play services Gradle plugin
© www.soinside.com 2019 - 2024. All rights reserved.