我克隆了快速入门消息应用程序,当应用程序从后台删除时它会收到通知。这样做的步骤:
- 启动应用程序
- 从最近的活动中删除应用程序。
现在,当我创建另一个项目并执行与在快速启动消息应用程序中所做的完全相同的事情时,当应用程序从最近的应用程序托盘中删除时,通知不会被传递。在日志中,我不断看到错误。
W GCM : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.example.hello (has extras) }
我的应用程序中的所有内容都与快速入门消息应用程序相同,但包除外。这是什么法术?:D
正在发送的有效载荷
{
"to": "asdasd....",
"priority": "high",
"notifications": {
"body": "Test body",
"title": "Test title"
},
"data": {
"key1": "value1",
"key2": "value2"
}
}
我正在使用一个 php 脚本来发送这个。使用 fcm 控制台发送有效负载(没有“数据”对象)时,会观察到相同的行为。
我做了一个 adb shell dumpsys 包 | grep 停止了 fcm quickstart 和我的项目。
对于快速启动应用程序:
User 0: ceDataInode=7733 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=0 instant=false
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=false notLaunched=false enabled=0 instant=false
对于我的应用程序:
User 0: ceDataInode=25321 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=0 instant=false
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false
我猜这两个用户是管理员,另一个是访客用户。我检查了设置,它确实提供了这样的选项。
对于我的应用程序,用户 999 的停止状态为真,即使未安装该应用程序也是如此。但是,在快速启动应用程序的情况下,状态为假。不知道为什么会发生这种情况以及这是否导致了问题。