Home unable to get the public ip in swift ios or mac os
Reply: 1

unable to get the public ip in swift ios or mac os

Siva Prasad
1#
Siva Prasad Published in 2018-01-13 07:59:22Z

How can I get public IP address of mobile or mac using swift without using third party URLs.

Can anyone help and also I have tried the apple portmapper.h class but it is returning nil.

let data = PortMapper.findPublicAddress()
print(data) 

Showing nil.

Ben Cummins
2#
Ben Cummins Reply to 2018-01-13 08:11:06Z

In most networks, the device a user is using rarely has a public IP... there will be a router or firewall etc and that might have a public IP or it might route through another device which has a public IP.

The reason for using a third party is because that third party would only be able to see the public IP that’s the devices network is using to reach them so you know it’s the correct IP.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320513 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO