这是NetInfo的第一个alpha发布版本。这个库为您提供对设备连接状态的即时访问,就像快照一样。
要运行示例项目,请克隆存储库,并首先从Example目录运行pod install
。
要使用NetInfo,请将其导入任何您需要使用它的地方:
创建一个GtNetInfo对象
GTNetInfo *netInfo = [[GTNetInfo alloc] init];
在这个对象内部,您可以找到4个属性,其中2个是布尔类型,2个是字符串。
//Is device currently connected?
BOOL connected = [netInfo isConnected];
//Is device currently connected to a Wi-Fi network?
BOOL connectedWifi = [netInfo isWifi];
//If device is currently connected to a Wi-Fi network, what's the SSID?
NSString* SSID = [netInfo currentSSID];
//If device is currently connected, which radio technology is using?
NSString* radioTecnology = [netInfo currentRadioTecnology];
注意:此Alpha版本在模拟器中不可用。
GTNetInfo通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中
pod "GTNetInfo"
Giuseppe Travasoni,[email protected]
GTNetInfo可在MIT许可证下获得。有关更多信息,请参阅LICENSE文件。