简体   繁体   English

Android-GCM在打开应用程序时从gcm接收通知

[英]Android - GCM receive notification from gcm when open app

I have implement application using GCM to receive push notification from my server, It works exactly but i have a problem. 我已经使用GCM来实现应用程序,以从服务器接收推送通知,它确实可以正常工作,但是我有问题。 When the app is not running i push a notification from server and i can not receive notification from GCM on device, it's OK. 当应用未运行时,我会从服务器推送通知,而我无法从设备上的GCM接收通知,没关系。 But when i open the app it still not receive the stored notification from GCM. 但是,当我打开该应用程序时,它仍然没有收到来自GCM的存储的通知。 Please give me some advice thanks. 请给我一些建议,谢谢。

When you manually stop/kill your app from the app settings screen you'll be in a state wherein GCM messages will still be delivered to the device, but your BroadcastReceiver will not be able to receive the subsequent com.google.android.c2dm.intent.RECEIVE broadcast. 当您从应用设置屏幕上手动停止/杀死应用时,您将处于GCM消息仍会发送到设备的状态,但BroadcastReceiver将无法接收后续的com.google.android.c2dm.intent.RECEIVE广播。 So what this means is the GCM message will essentially be lost. 因此,这意味着GCM消息实际上将丢失。 When you open up your app, you will not receive past GCM messages that you missed while your app was dead. 当您打开应用程序时,您将不会收到在应用程序死机时错过的过去的GCM消息。 There's no avoiding this if users are manually going into their settings and stopping your app. 如果用户手动进入其设置并停止您的应用程序,那将不可避免。

Note that this is different from the case where you remove your app from the recent task/multitasking list - in that case any BroadcastReceivers you have will still work, and you can either show a notification or perform some work at that time, and/or store something in persistence to be detected/used on the next time the user opens your app. 请注意,这与您从最近的任务/多任务列表中删除应用程序的情况不同-在这种情况下,您拥有的所有BroadcastReceivers仍将工作,并且您可以显示通知或在那时执行一些工作,和/或存储一些持久性,以便下次用户打开您的应用时可以检测到/使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM