Reputation: 967
i am trying download load the large videos(400 mb) into background cont.... until end of the video in iOS-7 using Xcode-5 . But After 10 or 5 min downloading is stop .
i wrote the code like below and i set the "background fetch mode is YES". Is There any wrong with my code.
Ref 2:
Question : How can i kept alive the my URL request upto my videos are downloaded in background mode?
Thanks in Advence.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier m_backgroundTaskId;
m_backgroundTaskId = [[UIApplication sharedApplication]
beginBackgroundTaskWithExpirationHandler:^(void) {
m_isWentBackground = YES;
[m_dataController saveUnfineshedDownoadsToFile];
[[UIApplication sharedApplication]
endBackgroundTask:m_backgroundTaskId];
m_backgroundTaskId = UIBackgroundTaskInvalid;
}];
}
Upvotes: 0
Views: 600
Reputation: 53301
You are doing it wrong, the beginBackgroundTaskWithExpirationHandler
will give you up to 10 extra minutes to download, but if you want real background download, you have to look into Background Transfer Service
You have 2 tutorials:
Upvotes: 2
Reputation: 2643
The beginBackgroundTaskWithExpirationHandler of UIApplication is supposed to be used a "task finisher". There is nothing wrong with your code, but it is the purpose of this code that is the problem. This operation will be kept alive for a maximum of 10 min or so, and it is the operating system which decides for how long the task will be operational. If you are downloading a 400mb video, it is not what you need. You should consider another way to do this task - Which is not in a background operation. A background operation, by Apple own definition can not last more than 10 minutes.
Perhaps, performing queued background operations, that will gradually append data, until you will have the complete video? Or doing this operation while app is not in background in another thread?
A 400mb video does not sounds like something a mobile device should do, as default.
Upvotes: 1
Reputation: 12405
Background processing is only allowed to a maximum of 10 minutes in ios unless your app is of one of the following types..
Refer the following for more info..
https://stackoverflow.com/a/9738707/919545
Upvotes: 1