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.