Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Discovery/DiscoveryManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
#import "AppStateChangeNotifier.h"

#import <SystemConfiguration/CaptiveNetwork.h>
#import <CoreLocation/CoreLocation.h>

@interface DiscoveryManager() <DiscoveryProviderDelegate, ServiceConfigDelegate>
@property(strong, nonatomic) CLLocationManager* locationManager;
@property (nonatomic, strong) dispatch_queue_t discoveryProviderQueue;
@end

Expand Down Expand Up @@ -132,6 +134,9 @@ - (instancetype) initWithAppStateChangeNotifier:(nullable AppStateChangeNotifier
[sself resumeDiscovery];
};

_locationManager = [[CLLocationManager alloc] init];
[_locationManager requestWhenInUseAuthorization];

[self startSSIDTimer];
}

Expand Down Expand Up @@ -253,6 +258,8 @@ - (void) unregisterDeviceService:(Class)deviceClass withDiscovery:(Class)discove

- (void) startSSIDTimer
{
[_ssidTimer invalidate];

_ssidTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(detectSSIDChange) userInfo:nil repeats:YES];
[_ssidTimer fire];
}
Expand All @@ -265,6 +272,10 @@ - (void) stopSSIDTimer

- (void) detectSSIDChange
{
if ([_locationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined ||
[_locationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
return;
}
NSArray *interfaces = (__bridge_transfer id) CNCopySupportedInterfaces();

__block NSString *ssidName;
Expand Down Expand Up @@ -495,6 +506,7 @@ - (void) stopDiscovery
if (!_shouldResumeSearch)
{
[self.appStateChangeNotifier stopListening];
[self stopSSIDTimer];
}
}

Expand Down