From d1a95e21a7cc5e50a1610ff860170d572470a052 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 24 Mar 2015 10:16:16 -0500 Subject: [PATCH] #1033 - Adding wifi network name attribute --- platform/ios/MGLMapboxEvents.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index a91a0ed94..563aa3cdb 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -14,6 +14,7 @@ #import #import #include +#import @interface MGLMapboxEvents() @@ -129,6 +130,7 @@ NSNumber *scale; [evt setValue:[[NSNumber alloc] initWithFloat:(100 * [UIDevice currentDevice].batteryLevel)] forKey:@"batteryLevel"]; [evt setValue:scale forKey:@"resolution"]; [evt setValue:carrier forKey:@"carrier"]; + [evt setValue:[self getWifiNetworkName] forKey:@"wifi"]; [evt setValue:[NSNumber numberWithInt:[self getContentSizeScale]] forKey:@"accessibilityFontScale"]; for (NSString *key in [attributeDictionary allKeys]) { @@ -294,4 +296,23 @@ NSNumber *scale; return results; } +- (NSString *) getWifiNetworkName { + + NSString *ssid = @""; + CFArrayRef interfaces = CNCopySupportedInterfaces(); + if (interfaces) { + NSDictionary *info = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0)); + if (info) { + ssid = info[@"SSID"]; + } else { + ssid = @"<>"; + } + } else { + ssid = @"<>"; + } + + return ssid; +} + + @end \ No newline at end of file