From 807d87f0f5883e1c697433eca381c860a74596f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 28 Jul 2015 14:29:12 -0700 Subject: [PATCH] Ignore redundant initial reachability notification on iOS 9 Fixes #1911. --- platform/ios/MGLMapView.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index afdc88cfc..e95305d0c 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -106,6 +106,7 @@ CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) mbgl::Map *_mbglMap; MBGLView *_mbglView; mbgl::DefaultFileSource *_mbglFileSource; + BOOL _isWaitingForRedundantReachableNotification; NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs; @@ -244,6 +245,10 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) object:nil]; MGLReachability* reachability = [MGLReachability reachabilityForInternetConnection]; + if ([reachability isReachable]) + { + _isWaitingForRedundantReachableNotification = YES; + } [reachability startNotifier]; // setup annotations @@ -415,9 +420,11 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) - (void)reachabilityChanged:(NSNotification *)notification { MGLReachability *reachability = [notification object]; - if ([reachability isReachable]) { + if ( ! _isWaitingForRedundantReachableNotification && [reachability isReachable]) + { mbgl::NetworkStatus::Reachable(); } + _isWaitingForRedundantReachableNotification = NO; } - (void)dealloc