Is it possible for an Android Library to receive push notifications?

南楼画角 提交于 2019-12-22 15:54:12

问题


Lets assume there exists the following:

  • Android App "A"
  • Android App "B"
  • Android Library "C"
  • Server (pushes notifications)

Is it possible for Library C to be registered to receive push notifications? In other words, I'd like App A and App B to use the dependency of Library C. I'd like for App A and App B to both receive push notifications when the Server pushes them to Library C. I was wondering if this is possible. If so, how?

The reason I ask is because it seems when registering an App with GCM, it must be registered/tied to an "App package name". I was wondering if this works with a "Library package".


回答1:


Yes that is possible, but it requires some configuration in the app that uses the library.

If you want your library to receive push messages without the app knowing it, that is however not possible.

I'd like for App A and App B to both receive push notifications when the Server pushes them to Library C

A server does not send a push to library C, it sends a push to a registration ID (or token). Google doesn't care whether that is tied to an "app" or a "library".

Also Receive Push Notifications into library project might have useful info for you.



来源:https://stackoverflow.com/questions/39869899/is-it-possible-for-an-android-library-to-receive-push-notifications

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