Yogesh Thakur
Yogesh Thakur

Reputation: 41

Get security type of currently connected wifi network for Mac OS X using cocoa

I need to find the security type (ex- WPA2, WEP) of the currently connected network on a Mac. I am targeting Mac OS 10.3. Seems that this can be done using the SCDynamicStore API. However, I am unable to find my way around this. Also I need to submit the app to the Mac App Store and hence do not want to go for any private code. Any pointers or a sample code would be very helpful. Thanks in advance.

Upvotes: 4

Views: 1128

Answers (1)

Almog_0
Almog_0

Reputation: 422

#import <CoreWLAN/CoreWLAN.h>

CWInterface* wifi = [[CWWiFiClient sharedWiFiClient] interface];
NSString *securityType = [wifi security];// this is given you  enum(some number) and u can do function that return the correct string with the name according this enum

this is the ENUM:

typedef NS_ENUM(NSInteger, CWSecurity)
{
    kCWSecurityNone                 = 0,
    kCWSecurityWEP                  = 1,
    kCWSecurityWPAPersonal          = 2,
    kCWSecurityWPAPersonalMixed     = 3,
    kCWSecurityWPA2Personal         = 4,
    kCWSecurityPersonal             = 5,
    kCWSecurityDynamicWEP           = 6,
    kCWSecurityWPAEnterprise        = 7,
    kCWSecurityWPAEnterpriseMixed   = 8,
    kCWSecurityWPA2Enterprise       = 9,
    kCWSecurityEnterprise           = 10,
    kCWSecurityUnknown              = NSIntegerMax,
} NS_ENUM_AVAILABLE_MAC(10_7);

Upvotes: 1

Related Questions