开发者

iPhone - retrieve images in background (PUSH)

I would like to build an app which retrieves images from my server. My problem is that I want it to work in the background and only when there is a 'new image' to l开发者_JAVA技巧oad.

It seems like what I need is very similar to PUSH notifications:

  • Work in the background
  • Only when there is 'something new' to load.

I guess what I want became possible with the new iOS4. Please tell me if this is feasible. Any links for how to even start thinking about it would be great. Thanks.


It depends on what background you mean.

If you mean that your application is running and you have some thread to get the image in the background thread, it is possible.

If you mean that your application is suspended and you still want to use PUSH notification and get the image. I am afraid that it is impossible. When your application is in the background, it has very limited amount of time that it can run to finish its current task. When that time is out, your application cannot do anything.

You can receive some push notification and local notification like GPS, server notification when your application is suspended, but you can only receive the server notification and cannot download the new image. Here is the instruction from Apple Dev documentation:

When the operating system delivers a local or push notification and the target application is not running in the foreground, it presents the notification (alert, icon badge number, sound). If there is a notification alert and the user taps the action button (or moves the action slider), the application launches and calls the UIApplicationDelegate method application:didFinishLaunchingWithOptions:, passing in the local-notification object or remote-notification payload. If the application is running in the foreground when the notification is delivered, the application:didReceiveRemoteNotification: or application:didReceiveLocalNotification: method of the application delegate is invoked.

More here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜