简体   繁体   English

Android通知

[英]Notifications for Android

I am looking to implement notifications on my app. 我希望在我的应用程序上实现通知。 The way I would like for this to work is when I put something on my website, that is connected to my app, it gives a notification automatically even if the app is not running. 我希望此方法的工作方式是,当我在连接到应用程序的网站上放置东西时,即使应用程序未运行,它也会自动发出通知。 I am just looking for the easiest way to accomplish this. 我只是在寻找实现此目的的最简单方法。 By the way the info that is added from the website is put into a listview in the app(if that helps at all). 顺便说一下,将从网站添加的信息放入应用程序的列表视图中(如果有帮助的话)。

The server needs to do a several things in order to talk GCM: http://developer.android.com/google/gcm/http.html 服务器需要做一些事情才能通话GCM: http : //developer.android.com/google/gcm/http.html

The client needs to do some registration and let your server know of the GCM registration ID: http://developer.android.com/google/gcm/client.html 客户端需要进行一些注册,并让您的服务器知道GCM注册ID: http : //developer.android.com/google/gcm/client.html

Those links will provide much more detail though 这些链接将提供更多细节

Your app may poll your side every N minutes/hours/days or you can use Google Cloud Messaging service. 您的应用可能每隔N分钟/小时/天对您的站点进行一次轮询,或者您可以使用Google Cloud Messaging服务。

GCM: Here is a link describing the usage of GCM with a PHP web server: GCM:这是描述GCM与PHP Web服务器的用法的链接:

http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

So if you have any update on your site this can notify GCM which will notify all registered users (their devices with your app running). 因此,如果您的网站上有任何更新,则可以通知GCM,GCM会通知所有注册用户(运行您的应用的设备)。

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

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