7

i get the device Mac and IP Address. But, don't get the device name.

any idea how to get more info if possible like "Network Utility" of device ?

Hejazi
  • 16,587
  • 9
  • 52
  • 67
Dhaval
  • 215
  • 2
  • 10
  • Hi Dhaval, Did you find any solution for this ? then please share – iBhavik Apr 25 '13 at 10:07
  • @i-bhavik i didn't get the Device name any get the device info. – Dhaval Apr 26 '13 at 09:42
  • Does anybody have any progress with this? I also want my app to find the device names, like iNet does. I can ping, I can read the ARP table, I cannot find the machine names. Any help would be appreciated! – Jelle Mar 14 '14 at 18:43

3 Answers3

11
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
Mani
  • 1,841
  • 15
  • 29
  • it give the any current device info but i have to get the different connect device in network that name/mac/ip address of that.i get the mac and ip but not get the device name. – Dhaval Jun 23 '12 at 07:25
  • Make this the new answer! It works correctly, and simply. The only edit I made was was to parse the data into `NSString` variables. –  Feb 22 '14 at 19:00
  • The first line does not longer work (see http://stackoverflow.com/questions/9396187/method-uidevice-currentdevice-uniqueidentifier-is-not-allowed-any-more-i-ne ) – Michael Dorner Jun 19 '14 at 07:33
3

On iOS 4.1+, you can do this: If you are looking for SSID Name..

import

- (id)fetchSSIDInfo
{
    NSArray *ifs = (id)CNCopySupportedInterfaces();
    NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
    id info = nil;
    for (NSString *ifnam in ifs) {
        info = (id)CNCopyCurrentNetworkInfo((CFStringRef)ifnam);
        NSLog(@"%s: %@ => %@", __func__, ifnam, info);
        if (info && [info count]) {
            break;
        }
        [info release];
    }
    [ifs release];
    return [info autorelease];
}
Deepak
  • 1,421
  • 1
  • 16
  • 20
  • thanks,but i want to get the different connected device of ping by my device the other device information not the network info.like i get the my device name "iPhone simulater" this type of name of other connected with router device information. if you have any idea then tell,please? – Dhaval Jun 23 '12 at 11:42
  • @Dhaval: Try to use this code in on device not in iPhone Simulator. When you use this on your device then you will get the router SSID, Mac Address etc. – Deepak Jun 25 '12 at 04:42
1
#import <ifaddrs.h>
#import <arpa/inet.h>

- (NSString *)getIPAddress {    
    NSString *address = @"error";
    struct ifaddrs *interfaces = NULL;
    struct ifaddrs *temp_addr = NULL;
    int success = 0;
    // retrieve the current interfaces - returns 0 on success
    success = getifaddrs(&interfaces);
    if (success == 0) {
        // Loop through linked list of interfaces
        temp_addr = interfaces;
        while(temp_addr != NULL) {
            if(temp_addr->ifa_addr->sa_family == AF_INET) {
                // Check if interface is en0 which is the wifi connection on the iPhone
                if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
                    // Get NSString from C String
                    address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];               
                }
            }
            temp_addr = temp_addr->ifa_next;
        }
    }
    // Free memory
    freeifaddrs(interfaces);
    return address;

} 
Mani
  • 1,841
  • 15
  • 29