这是我的清单
<service android:name=".fcm.PshycoFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".fcm.PshycoFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
当应用程序处于后台并且通知到达时,默认通知将会运行并且不会运行我的代码onMessageReceived
.
这是我的onMessageReceived
代码.如果我的应用程序在前台运行,而不是在后台应用程序时,则调用此方法.如何在应用程序处于后台时运行此代码?
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See …
Run Code Online (Sandbox Code Playgroud) 我希望在收到通知时自动打开应用程序,Firebase和新的FCM通知是否可以实现?
我知道我可以设置click_action,但这只是为了自定义通知点击会启动哪些活动,我需要在收到通知时自动启动的内容.
我尝试了快速启动消息传递firebase示例,并且有一个onMessageReceived()方法,但只有在应用程序位于前台时它才有效.应用程序在后台运行时是否会执行某些操作?GCM可以通过直接启动广播接收器的活动意图来做我喜欢的事情,广播接收器在收到通知时调用.
android firebase firebase-cloud-messaging firebase-notifications