由于工作需求,这几天一直在研究IOS
如何获取到的电量及网络类型
做之前我们首先要找到IOKit.tbd这个动态库及两个API头文件(IOPowerSources.h和IOPSKeys.h)
在Xcode ->显示包含内容->Contents->Developer->Platforms->iPhoneOS.platform->Developer->SDKs->iPhoneOS.sdk->System->Library->Frameworks
下找到IOKit.framework 并找到IOKit.tbd这个库及IOPowerSources.h和IOPSKeys.h
Unity 代码:
[DllImport("__Internal")]
static extern int IOS_GetPhoneElectricity();
[DllImport("__Internal")]
static extern string IOS_GetNetworkType();
IOS代码: