FCM服务:
public class FCMService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.i(Constants.TAG,"onMessageReceived");
Log.i(Constants.TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage.getData().size() > 0) {
Log.d(Constants.TAG, "Message data payload: " + remoteMessage.getData());
}
if (remoteMessage.getNotification() != null) {
Log.d(Constants.TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
}
compile 'com.google.firebase:firebase-messaging:10.2.6'
显示:
<service android:name="communications.FCMService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
-我发送消息
from FCM console
-我从java服务器发送消息,消息没有到达。Java server在消息发送时显示OK。
-之前,我错误地导入了FCM库,这个错误得到了解决。当每次发送消息时都会出现过去的错误时,Android上就会出现异常。现在什么也没有收到。
-我在Android设备上有一个互联网连接,我通过GCM(不是FCM)从我过去实现的另一个应用程序接收消息。
一些日志带有“fcm”过滤器。我在发送消息时收到此日志。
08-14 12:09:25.640 800-4739/? D/PowerManagerService: acquireWakeLockInternal: lock=862109980, flags=0x1, tag="wake:bidsy.app.bidsy/communications.FCMService", ws=null, uid=10354, pid=24073
08-14 12:09:25.640 800-4739/? D/PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="wake:bidsy.app.bidsy/communications.FCMService", packageName=bidsy.app.bidsy, ownerUid=10354, ownerPid=24073, workSource=null
08-14 12:09:25.683 24073-24073/bidsy.app.bidsy D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@1c269013 className=communications.FCMService packageName=bidsy.app.bidsy intent=null}
08-14 12:09:25.683 24073-24073/bidsy.app.bidsy D/ActivityThread: SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@1c269013 className=communications.FCMService packageName=bidsy.app.bidsy intent=null}
08-14 12:09:25.685 24073-24073/bidsy.app.bidsy D/ActivityThread: SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@1c269013 startId=1 args=Intent { act=com.google.firebase.MESSAGING_EVENT pkg=bidsy.app.bidsy cmp=bidsy.app.bidsy/communications.FCMService (has extras) }}
08-14 12:09:25.684 24073-24073/bidsy.app.bidsy D/ActivityThread: SVC-Calling onStartCommand: communications.FCMService@3e035250, flags=0, startId=1
08-14 12:09:25.691 800-1592/? D/PowerManagerService: releaseWakeLockInternal: lock=862109980 [wake:bidsy.app.bidsy/communications.FCMService], flags=0x0, total_time=52ms
08-14 12:09:25.691 800-1592/? D/PowerManagerNotifier: onWakeLockReleased: flags=1, tag="wake:bidsy.app.bidsy/communications.FCMService", packageName=bidsy.app.bidsy, ownerUid=10354, ownerPid=24073, workSource=null
08-14 12:09:25.692 24073-24073/bidsy.app.bidsy D/ActivityThread: SVC-Destroying service: communications.FCMService@3e035250
当然,我不会在日志中使用任何过滤器来检查消息是否到达onMessageReceived
Can't receive the push notification message
在详细查看整个日志后,我发现当我发送消息时,会发生以下Firebase错误
:
D / FirebaseMessaging: Unknown intent action: com.google.firebase.MESSAGING_EVENT
:
I faced a issue while using the older version of FCM i.e 10.2.6 Unknown intent action: com.google.firebase.MESSAGING_EVENT