【发布时间】:2018-03-01 19:10:10
【问题描述】:
我正在使用 firebase 云消息传递,我想知道是否可以向离线设备发送通知,然后在它上线后接收它。
客户端
我通过主题向虚拟设备发送通知 (Nexus 5 API 27) 我使用以下依赖项:
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
服务器端
我有一个发送 POST 请求的 Java 服务器:
网址: https://fcm.googleapis.com/v1/projects/PROJECT_ID/messages:send
标题
Authorization : Bearer <token OAuth2>
Content-Type : application/json
身体
{
"message": {
"topic":"topicName",
"data": {
"infoKey": "infoValue",
}
}
}
虚拟机启动后,我很快就会收到通知。 但是如果我的虚拟设备关闭并且我的服务器发送了通知,即使等待超过 1000 万,客户端也不会收到通知。 正常吗? 我觉得我做错了什么,因为当我阅读文档时,通知应该被存储,直到有人阅读它:
https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
有谁知道我是不是弄错了,还是我太看重FCM的功能了?
谢谢。
【问题讨论】:
-
所以您希望在完全关闭的虚拟设备上收到一条消息?
-
当我启动我的应用程序时,我希望在我离线时接收特定主题中发送的通知。
-
FCM 会将消息排队最多一定时间 (TTL) 并尝试重新传递,直到该持续时间到期。如果您看到不同的行为,您可能需要联系 Firebase 支持。 firebase.google.com/support/contact/troubleshooting
-
好的,我会联系他们的。感谢大家的帮助
标签: android firebase firebase-cloud-messaging