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.
Arunkumar.P
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.
Arunkumar.P
登錄到iOS開發中心,並搜索「後臺任務」,你會發現你所需要的文檔。
爲了更清楚地說明,每當您的應用程序要開始一個可能需要一段時間才能完成的任務並且即使在後臺應該仍然活着時,您應該在這樣的任務開始之前聲明一個UIBackgroundTaskIdentifier,並告訴iOS這是需要在後臺運行的任務。而且你還必須確保當你的任務結束時,你應該總是告訴iOS它已經完成了,並且不需要特別的背景許可。
您的代碼應該是這樣的:
//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];
}
網絡,同時在後臺狀態下暫停。如何在後臺狀態下恢復網絡。 – 2010-12-20 09:16:22