我已经根据文档实现了FCM,并且它在Android版本4.4(Kitkat)及以上版本上工作得很好,并且不适用于4.3(Jelly Bean)及以下版本。根据FCM文档,它说所需的最低版本是4.0,我有游戏服务。 FCM正在生成刷新令牌,当我使用它从我的服务器或FCM控制台发送消息时,它无法正常工作。以下是FCM的Manifest条目。
<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>
任何建议表示赞赏。谢谢。
答案 0 :(得分: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'
答案 1 :(得分: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