0

这个问题是我之前的问题(没有收到任何回复)的扩展/替代。与其尝试实现推送通知,我还可以定期轮询服务器。但是这个轮询需要在分配给后台任务的 10 分钟之后继续。

iOS中是否有类似定时任务的东西(想想cron-jobs / daemons)?

我能想到的另一种扭曲方式是,如果我在我的应用程序中集成 twitter 框架并让我的服务器发送直接消息,它会唤醒我的应用程序吗?我知道这听起来真的很蹩脚,因为如果通知被接收,iOS 将如何知道将通知发送到哪个应用程序......

谢谢并期待一些回复:)

4

2 回答 2

0

为什么你反对使用推送通知来做任何你想做的事情?Urban Airship似乎允许在其基本计划中每月免费发送 1000000 条推送消息。

反正我想不出别的办法了。

于 2012-10-25T04:26:55.457 回答
0

What you're trying to achieve is very likely a "no" but I did do some pretty some hackish stuff back then, so this may or may not work for you (no guarantee):

When an app receives a notification, it triggers the app delegate's applicationDidLoad() method and the notification object is stored in the "launchOptions" parameter.

In this method, you MAY be able to execute an action to poll your server.

So what I was thinking was, setup a local notification to fire at the date you desire. Local notification are like push notification, they can execute even if your app is terminated (killed from the background process)

Then in your app delegate's didFinishLaunchingOptions(), you can check to see if it's the matching notification, if yes, then execute your desire server polling logic, else ignore.

Note: if your server polling logic is in another view controller, do realise these view controllers may not actually be initiated until you actually click on the tab to view them. Now because your app is terminated and not running, you obviously can't tap on a tab.

The second hack is to call the getter "view" method of your view controller containing the server polling logic e.g:

// force iOS to initialize the view controller
[MyCustomVC view];

As you can see, very hackish and not recommended.

于 2012-10-25T05:09:54.767 回答