1

I am working on streams. I want the stream should be open for 10 minutes in background and after 10 minutes I want to close it. I have done like this...

`__block UIBackgroundTaskIdentifier bgTask;
    bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
        [application endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
      [self resumeStream];
});`

In this case The application is running only for 3 mins in backgroun and after that Its disconnecting.

Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136
AMohan
  • 534
  • 1
  • 6
  • 15
  • Make your stream timeout for 10 mint in background – AsifHabib Mar 27 '14 at 11:39
  • @AsifHabib It is not running for 10 mins. It;s only running for 3 mins – AMohan Mar 27 '14 at 11:40
  • There must be a timeout for stream! if stream is disconnected background task can do nothing! so you must have to set timeout of your stream as well! – AsifHabib Mar 27 '14 at 11:41
  • This is the new behavior for IOS7. Please read release note for ios7 – DareDevil Mar 27 '14 at 11:42
  • @DareDevil What do you mean? – Woodstock Mar 27 '14 at 11:50
  • @DareDevil I have changed it to `CGFloat delayInSeconds = 2*60.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ [self startClient]; });` but still of no use. – AMohan Mar 27 '14 at 11:54
  • You will get approximately 3 min to finish long background task from ios 7. – DareDevil Mar 27 '14 at 11:54
  • @DareDevil Yes. even my application is for iOS7 and above only. But I need 10 mins. How can I do that. Is it possible to do? – AMohan Mar 27 '14 at 11:57
  • Not possible in normal mode. In voip mode its possible to keep connection alive. But if your app does not have voip functionality , apple will reject it. – DareDevil Mar 27 '14 at 12:04
  • @DareDevil But I am not using any of those listed services. I have get to know that if I mention any of those modes adn if I don't use those in application it might be possible to reject the application by Apple. – AMohan Mar 27 '14 at 12:06
  • @DareDevil interesting - I haven't tested. I can't find any official documentation saying they changed the old 10 min to 3mins? – Woodstock Mar 27 '14 at 12:12

1 Answers1

0

The maximum background time has changed from 10 minutes in iOS 6 to 3 minutes in iOS 7.

See background task interval period in IOS 7

Community
  • 1
  • 1
user3486184
  • 2,147
  • 3
  • 26
  • 28