Search code examples
androidfirebasepush-notificationfirebase-cloud-messagingpayload

FCM Push notification is not opening the application


I am receiving FCM Push notifications but the app is not opened while taping the notification that are delivered in the system tray while the application is in the background.

My Payload from Back End looks like this:

Array(
    [registration_ids] => Array
        ([0] => some value)

    [priority] => high
    [notification] => Array
        (
            [body] => Booking Cancelled: Your recent Booking attempt for Sound mix was declined.
            [title] => Booking Rejected
            [click_action] => USER_BOOKING_REJECTED
            [sound] => default
        )

    [data] => Array
        (
            [type] => USER_BOOKING_REJECTED
            [booking_id] => 331
        )
)

I added this USER_BOOKING_REJECTED as action in Manifest for the concerned Activity.

Like this:

 <activity
            android:name=".view.activity.HomeActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
                <action android:name="USER_BOOKING_APPROVED" />
                <action android:name="USER_BOOKING_REJECTED" />
                <action android:name="USER_BOOKING_AUTO_REJECTED" />
                <action android:name="USER_CANCEL_BOOKING" />
                <action android:name="USER_BOOKING_REMINDER" />
                <action android:name="USER_INVOICE_EDIT" />
                <action android:name="USER_INVOICE_NEW" />
                <action android:name="USER_INVOICE_REFUND" />
                <action android:name="USER_INVOICE_REMOVE" />
                <action android:name="NEW_MESSAGE" />
                <action android:name="SP_BOOKING_REMINDER" />
                <action android:name="SP_BOOKING_NEW" />
                <action android:name="SP_BOOKING_CANCEL" />
                <action android:name="SP_INVOICE_PAYMENT" />
                <action android:name="SP_NO_FUTURE_SLOT" />

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="@string/host"
                    android:pathPrefix="@string/home_path"
                    android:scheme="http" />

            </intent-filter>
        </activity>

Even though I get the notification in the system tray, the app is not opened while taping the notification. Any Help?


Solution

  • You need to make separate <intent-filter>s for separate <action>s in the AndroidManifest.xml.

    Try to add just this:

            <intent-filter>
                <action android:name="USER_BOOKING_REJECTED" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>