- (NSString *)externalIPAddress {
// see https://stackoverflow.com/questions/27708887/objective-c-how-to-get-the-public-ip-address-of-the-device/27709110#27709110
// http://myipdoc.com/ip.php
NSString *publicIP = [NSStringstringWithContentsOfURL:[NSURLURLWithString:@"https://icanhazip.com/"] encoding:NSUTF8StringEncodingerror:nil];
publicIP = [publicIP stringByTrimmingCharactersInSet:[NSCharacterSetnewlineCharacterSet]];
return publicIP;
}
留言
張貼留言