在应用终止或在后台运行时收到fcm通知时,会自动打开应用

时间:2020-01-28 11:36:09

标签: android push-notification firebase-notifications

任何人如何解决此问题,请根据此问题向我发送任何解决方案

收到

fcm通知,但应用未打开如何处理

public void onMessageReceived(RemoteMessage remoteMessage) {

        Intent intent = new Intent(INTENT_FILTER);
        sendBroadcast(intent);

        if (remoteMessage.getData().size() > 0) {
            utils.print(TAG, "From: " + remoteMessage.getFrom());
            utils.print(TAG, "Notification Message Body: " + remoteMessage.getData());
            //Calling method to generate notification
            if (SharedHelper.getKey(this,"loggedIn").equalsIgnoreCase(getString(R.string.True))) {

                sendNotification(remoteMessage.getData().get("message"));
            }
        }

1 个答案:

答案 0 :(得分:0)

您应该像这样在Manifest中声明firebase服务类:

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