ASIHTTPRequest and background download

2019-05-27 10:26发布

I was planning to use ASIHttprequest to download an mp3 file. i will need to use queues because there can be multiple simultaneous downloads.

I saw that you can use

[request setShouldContinueWhenAppEntersBackground:YES];

if you want to support background execution... If the file completes in the background, how can i handle this?

will the delegates be called anyway? can i make one of those notification badges from the delegate if the app was in background whenn the delegate was called?

PS: I AM on iOS4, and background exec is supported.

1条回答
你好瞎i
2楼-- · 2019-05-27 11:06

The requestFinished method should still be called before the endBackgroundTask: is called on the download; however, to ensure the functionality you want gets executed (a notification badge or something), you should use a UIBackgroundTask.

Basically the idea is that you create a new background task and use beginBackgroundTaskWithExpirationHandler: in the delegate finished method and then do whatever you want in the background task (see the apple dev guide about it here).

Make sure you call endBackgroundTask on your task after you are done!

查看更多
登录 后发表回答