我收到 FCM 推送通知,但在应用程序处于后台时点击系统托盘中传送的通知时应用程序未打开。
来自后端的我的有效负载如下所示:
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
)
)
我将此 USER_BOOKING_REJECTED 添加为相关 Activity list 中的操作。
像这样:
<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>
即使我在系统托盘中收到通知,但在点击通知时应用程序并未打开。有什么帮助吗?
最佳答案
你需要单独制作<intent-filter>
s 用于单独的 <action>
在 AndroidManifest.xml 中。
尝试只添加这个:
<intent-filter>
<action android:name="USER_BOOKING_REJECTED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
关于android - FCM 推送通知未打开应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48805431/