In Ihrer AppDelegate.m Datei wird diese Methode aufgerufen, wenn der Benutzer die Home-Taste drückt und die App in den Hintergrund geht (hier können Sie Ihre Verbindung live halten, aber Sie sollten die Apple Dokumentation zu Hintergrundaufgaben lesen, weil die Verbindung nicht für immer lebt sein kann, wenn die App im Hintergrund bleibt Es gibt auch andere Möglichkeiten, um Ihre App auf dem neuesten Stand wie Update auf Push-Benachrichtigung etc.) zu halten.
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
und diese Methode, wenn die Anwendung aufgerufen wird wird beendet (vollständig vom Multitasking geschlossen).
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
Sie können Ihre Verbindungen innerhalb dieser Methoden behandeln.
@ dandan78 das ist nur für den Hintergrund, ich möchte eine Benachrichtigung für wann die App ausgesetzt ist. –