is there way capture event occurs when user connects particular wifi network in ios app. fine if can achieved using private library doesn't require super user privileges (jail break). want capture changing event of connected ssid.
i recommend using larme posted, , setting nstimer check every second or so, ssid of current network is, if detect change, whatever need do. keep in mind, changing wifi networks not happens instantaneously, having 1 second resolution not bad
in applicationdidfinishloading
nstimer *ssidtimer = [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(fetchssidinfo) userinfo:nil repeats:yes];
in appdelegate
- (id)fetchssidinfo { nsarray *ifs = (__bridge_transfer id)cncopysupportedinterfaces(); nslog(@"supported interfaces: %@", ifs); id info = nil; nsstring *ifnam = @""; (ifnam in ifs) { info = (__bridge_transfer id)cncopycurrentnetworkinfo((__bridge cfstringref)ifnam); nslog(@"%@ => %@", ifnam, info); if (info && [info count]) { break; } } if ([info count] >= 1 && [ifnam caseinsensitivecompare:prevssid] != nsorderedsame) { // trigger event prevssid = ifnam; } return info; }
something that. can not check if code typo free not in front of mac, should not different
Comments
Post a Comment