0
             I am sending email using SMTP Implementation .Now i am switching to another app network to be suspend. How to handle network not to be suspended.

Regards,

Arunkumar.P

KingofBliss
  • 15,055
  • 6
  • 50
  • 72

1 Answers1

0

Login to iOS Dev Center, and search "background task", you'll find the document you need.

To be more clear, every time your app is to start a task that may take some time to finish and should be alive even in the background, you should declare a UIBackgroundTaskIdentifier before such a task starts, and tell the iOS that this is the task that needs to run in the background. And you also have to make sure that when your task ends, you should always tell iOS that it's finished and no more special background permission is needed.

Your code should look like this:

//right before your critical task starts
UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid;
newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];

//immediately after your critical task finishes
if (newTaskId != UIBackgroundTaskInvalid) {
    [[UIApplication sharedApplication] endBackgroundTask: newTaskId];
}
Di Wu
  • 6,436
  • 3
  • 35
  • 51