可以使用推送通知来运行代码而无需通知用户吗? [英] Can push notifications be used to run code without notifying user?

查看:106
本文介绍了可以使用推送通知来运行代码而无需通知用户吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要每24小时与服务器通信(刷新它的数据)。即使应用程序未打开也不在后台,这种情况需要发生。

I have an app which needs to communicate with a server (to refresh it's data) once every 24 hours. This needs to happen even if the app is not open, nor in the background.

理想情况下我想要的是:

Ideally what I'd like is:


  • 我的服务器每隔24小时向iPad发送推送通知

  • 这会唤醒应用程序,并运行刷新数据所需的代码

  • 然后放弃通知

这是否有可能?

用户是否仅在用户点击通知后醒来?或者我可以在显示通知之前运行一些代码吗?
我甚至可以丢弃通知消息吗?

Is any of this possible?
Is the app only woken up AFTER the user clicks on the notification? Or can I run some code before showing the notification? Can I even discard the notification message?

如果推送通知不是正确的方法,那么???

If Push notifications are not the right way to do this, what is???

谢谢你们!

推荐答案

随着iOS 7的发布,最终可以使用远程/静音通知。它们与推送通知的工作方式相同,但不是立即向用户发出警报,而是可以启动后台获取模式并上传/下载新内容。

With release of iOS 7 this is finally possible using Remote/Silent notifications. They work same as Push notifications but instead of alerting the user immediately they can fire up background fetch mode and upload/download new content.

这是一个简单的教程: http:// www。 objc.io/issue-5/multitasking.html

Here is simple tutorial:http://www.objc.io/issue-5/multitasking.html

这篇关于可以使用推送通知来运行代码而无需通知用户吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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