我正在使用Firebase,并在应用程序处于后台时测试从我的服务器向我的应用发送通知.通知成功发送,甚至出现在设备的通知中心,但是当通知出现或甚至我点击它时,我的FCMessagingService内的onMessageReceived方法永远不会被调用.
当我在我的应用程序位于前台时对此进行测试时,调用了onMessageReceived方法,一切正常.当应用程序在后台运行时会出现此问题.
这是预期的行为,还是有办法解决这个问题?
这是我的FBMessagingService:
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class FBMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.i("PVL", "MESSAGE RECEIVED!!");
if (remoteMessage.getNotification().getBody() != null) {
Log.i("PVL", "RECEIVED MESSAGE: " + remoteMessage.getNotification().getBody());
} else {
Log.i("PVL", "RECEIVED MESSAGE: " + remoteMessage.getData().get("message"));
}
}
}
Run Code Online (Sandbox Code Playgroud) 当用户在后台点击通知时,我正在尝试打开特定活动.从Docs中,我已经知道必须在有效负载中添加click_action,并在App中使用intent过滤来处理它.但是,如何通过Firebase控制台在Firebase通知中添加click_action?我也对任何其他工作开放.提前致谢.
android android-notifications firebase-cloud-messaging firebase-notifications
我实施了Firebase并测试了Firebase通知.当应用程序在前台我没有问题时,我实现了一个扩展FirebaseMessagingService并处理onMessageReceived中的消息和数据的服务
当应用程序处于后台时,我遇到问题,我想发送一个通知,打开一个特定的活动并完成我计划做的事情,而不仅仅是打开应用程序.
我按照Firebase指南中的说明执行了操作,但我无法启动特定活动.
这里的清单:
<activity android:name=".BasicNotificationActivity">
<intent-filter>
<action android:name="OPEN_ACTIVITY_1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
这里是Firebase控制台.我必须在这些字段中编写什么来打开我的"BasicNotificationActivity"?
android firebase firebase-cloud-messaging firebase-notifications