从数据库中获取谷歌云消息 [英] Google cloud messaging by fetching from database

查看:222
本文介绍了从数据库中获取谷歌云消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作得到消息从服务​​器到android应用。现在,我想使用谷歌云消息得到推送通知的。我想要在我的应用

I'm working on getting news from server into the android application. Now I'm thinking of getting push notification using google cloud messaging. What I'm trying in my application is


  1. 定期检查服务器是否有加入到数据库中的任何新数据。

  2. 如果是的话那么做一个推送通知。

我没有看到它做这件事的任何教程。我只找到Android的code。请帮我在这。我是新手,这个概念。

I'm not seeing any tutorial which does this thing. I only found android code. Please help me on this. I'm newbie to this concept.

感谢。

推荐答案

您必须为这个选项:

1。要联系从定期应用服务器,并检查是否有任何新的通知。如果是这样你得到的数据并显示给用户。

1.. To contact your server from the app periodically and check if there are any new notifications. If so you get the data and show it to the user.

- 可以通过安排一个报警器,也许每天一次,启动该不服务器检查的服务和通知用户执行此操作。 (这可能是一个好的解决方案,如果你知道新通知将出现在固定的时间间隔,我用了一个具有显示新闻周刊每周五中午的应用程序)

-You can do this by scheduling an alarm, maybe once a day, that starts a service that does the server checking and notifying the user. (this can be an ok solution if you know that new notifications will appear at fixed time intervals, i used it for an app that has show weekly news each Friday at noon)

2 ..谷歌云端通讯的Andr​​oid

2.. Google Cloud Messaging for Android

谷歌云端通讯的Andr​​oid(GCM)是允许您从您的服务器发送数据到用户的Andr​​oid设备,也从同一连接上设备接收信息的服务。该GCM服务处理邮件和交付排队到目标设备上运行的目标Android应用程序的各个方面。 GCM是完全免费的,无论你的信息需求有多大,而且没有配额。

Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection. The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device. GCM is completely free no matter how big your messaging needs are, and there are no quotas.

http://developer.android.com/google/gcm/index.html

如果您希望能够在任何给定的时间向用户发送通知我推荐这个。

I would recommend this if you want to be able to send notifications to users at any given time.

您对developer.android,其安全可靠好的教程,你将不得不对过程的完全控制。

You have nice tutorials on developer.android, its safe and reliable and you will have complete control over the process.

我目前正在实施选项2,所以我可以在其上更新我的经验,一旦其完成。

I am currently working on implementing option 2, so i can update my experience on it once its done.

和这里是在这一个一个实现教程: HTTP://www.vogella。 COM /用品/ AndroidCloudToDeviceMessaging / article.html

and here is an implementation tutorial on this one: http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html

这篇关于从数据库中获取谷歌云消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆