It's not ideal but I have solution based on Nanayakkara project. AppDelegate creates MyConnectionManager
which is observed on networkStatusChanged
selector:
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("networkStatusChanged:"), name: ReachabilityStatusChangedNotification, object: nil)
Reach().monitorReachabilityChanges()
Each time connection state was changed manager calls networkStatusChanged
and checks if connection is lost & top view isn't special connection view with message like "Please check your internet connection". If it isn't manager retrieves topController from sharedApplication
func topController() -> UIViewController? {
if var topRootController =
UIApplication.sharedApplication().keyWindow?.rootViewController {
while((topRootController.presentedViewController) != nil) {
topRootController = topRootController.presentedViewController!
}
return topRootController
}
return nil
}
and calls presentViewController
with ConnectionViewController
.