how to run GcmListenerService in foreground

假如想象 提交于 2019-12-01 16:12:39

This question is quite old but I think it's worth to answer for the benefit os the future readers.

With GCM (or the new FCM) there is NO NEED to keep GCMListenerService in foreground.
Indeed there is no need to keep the app running at all.

When a GCM message is received by the system, your app will be started and the relevant service (GCMListenerService in GCM or FirebaseMessagingService in FCM) will be executed.

The real issue raised by this post is:
GCM messages are not arriving when the application is not running.

This is due to a special feature of xiaomi that blocks GCM messages.
see: Autostart whitelist inside the Security section.
http://en.miui.com/thread-117992-1-1.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!