I have several iOS apps that all use the same port to listen for a network beacon. On the main view I use viewWillDisappear to close the port when another view is opened, w
The easiest way to handle this is to register to receive the UIApplicationWillResignActiveNotification notification in your view controller.
The event is issued upon a home button press, lock and upon a phone call
- (void) applicationWillResign{
NSLog(@"About to lose focus");
}
- (void) myVcInitMethod {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillResign)
name:UIApplicationWillResignActiveNotification
object:nil];
}