windows phone 8:如何检查数据库(服务器)上是否一直有新消息(即使应用程序没有运行)? [英] windows phone 8: how to check if there are new messages on the database (server) all the time (even if the app is not running)?

查看:20
本文介绍了windows phone 8:如何检查数据库(服务器)上是否一直有新消息(即使应用程序没有运行)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发 Windows 桌面应用程序已经很多年了,但刚刚开始开发 Windows Phone 8 应用程序,所以,你可以想象,我有很多问题和疑惑.

I’ve been developing Windows desktop applications for many years, but just started developing Windows Phone 8 applications so, as you can imagine, I have many questions and doubts.

这是我目前的问题:

我需要一个应用程序来检查服务器数据库中是否有新消息/通知,即使应用程序没有运行,并在手机上显示它(以某种方式,不确定如何).最后,我想要类似于 Facebook 应用程序(或其他应用程序)的东西,即使我不使用手机,它也会不断检查是否有新消息.我怎样才能做到这一点?是否有任何教程或指南可以解释这一点?

I need an application to check any certain time if there are new messages / notifications in the server database, even if the application is not running, and show it (in some way, not sure how) on the phone. At the end, I want something similar to Facebook application (or others) that checks constantly if there are new messages even if I’m not using the phone. How can I do that? Is there any tutorial or guide that explains that?

非常感谢

推荐答案

Windows Phone 有两种机制可以定期检查数据源并显示通知:

There's two mechanisms available on Windows Phone to periodically check a data source and display notifications:

  1. 推送通知:服务器直接向手机发送通知.它提供了最佳的用户体验,因为通知是(几乎)即时发送的,并且因为所有处理都是在服务器端完成的(因此它不会影响手机的自主性).明显的缺点是您需要一个服务器基础设施来发送通知.

  1. Push notifications: the server directly sends the notification to the phone. It provides the best user experience, because the notification is send (nearly) instantaneously, and because all the processing is done server-side (so it doesn't impact the phone's autonomy). The obvious drawback is that you need a server infrastructure to send the notifications.

后台代理:您的应用程序在后台运行,定期唤醒(每 30 分钟左右),并允许运行大约 15 秒.在这 15 秒内,您可以检查数据源,并在需要时显示通知.两个主要缺点是您无法选择后台代理何时执行(因此通知可以延迟 30 分钟显示),并且会影响电池寿命.

Background agents: your application runs in background, is woke up periodically (every 30 minutes or so), and is allowed to run for about 15 seconds. During those 15 seconds, you can check your data source, and display a notification if needed. The two major drawbacks are that you can't choose when you're background agent executes (so the notification can be displayed 30 minutes late), and it'll have an impact on the battery life.

这篇关于windows phone 8:如何检查数据库(服务器)上是否一直有新消息(即使应用程序没有运行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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