Ipify
从 Ipify 的 API 服务 获取您的公网 IP 地址。
用法
import Ipify
Ipify.getPublicIPAddress { result in
switch result {
case .success(let ip):
print(ip) // "210.11.178.112"
case .failure(let error):
print(error.localizedDescription)
}
}
要求
- Swift 4
- iOS 10+ / macOS 10.10+
安装
###CocoaPods Ipify 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod "Ipify"
###Carthage
github "vincent-peng/swift-ipify"
作者
彭文诚, [email protected]
致谢
非常感谢 Randall Degges 运行和维护 ipify!
许可证
Ipify 使用 MIT 许可证。更多信息请查看 LICENSE 文件。