Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not calling didBecomeActive if background task expires

Here is the situation:

I am picking a large video using imagepicker. Obviously the picker will take a bit of time to compress the video. So to ease user experience I have enabled background task for it.

Now here comes the issue:

If user choose a video and and tap the home button, application goes to background and continue compressing video for next 600 secs. And the background task expires. In the expiration handler I have stopped my background task.

Now if the user is resuming app after the background expiration

- (void)applicationDidBecomeActive:(UIApplication *)application

is not being invoked. Can anyone explain me why this happens?

like image 623
Deepukjayan Avatar asked Jan 03 '13 09:01

Deepukjayan


1 Answers

When the background tasks expires, your app will really be closed! So it's not becoming active again, it's launching.

You should handle stuff in your expiration handler or/and when your background task ends successfully. Both situations, you need to set the background_task as invalidated.

If your app goes to background while converting the video, and then user open it again BEFORE the task end or the background task expires, then you should see the app calling applicationDidBecomeActive.

I assume you know it, but maybe you are missing the multitask properties in your Info.plist file, so your app isn't accepting background tasks the way you expect.

like image 71
Douglas Fischer Avatar answered Nov 10 '22 10:11

Douglas Fischer