android - 当应用程序被杀死或在后台时收到 fcm 通知时自动打开应用程序
问题描述
如何解决这个问题任何人给我根据这个问题的任何解决方案
收到 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"));
}
}
解决方案
你应该像这样在 Manifest 中声明 firebase 服务类:
<service android:name="your_service>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
推荐阅读
- javascript - 如何检查 a 中的值是否为 null 并显示基于另一个中的文本?
- python - 如何将对象给关键字参数作为键
- php - 如何在 html 表单操作中正确编写此 php 代码?
- react-native - 如何在函数外部使用变量来反应本机?
- javascript - 将多个导入组合到一个打字稿中
- amazon-dynamodb - DynamoDB ADD 事务无明显原因间歇性失败
- python - Python range().count() 就像 "contains()" (?)
- r - 如何在 R 程序中读取格式未知且编码未知的 csv 文件?(提供的示例文件)
- python - 在 Python 中查找前百万个自然数的乘积
- python - 我可以在 python 中使用什么方法来确定基于过去数据的值的可能性?