我正在尝试在 C# 应用程序上连接时获取 Iphone 的 UDID。我发现我可以使用 IMobileDevice-net nuget 包来做到这一点,但我找不到有关如何使用其类的更多文档。
有谁知道我在哪里可以找到文档或示例代码?
最佳答案
IMobileDevice-net
文档的链接似乎已损坏。但你可以在 Documentation of IMobileDevice-net 找到它
根据为IMobileDevice-net
提供的示例代码,如果已知设备的名称
,则可以找到设备的UDID
。相同的代码片段是:
ReadOnlyCollection<string> udids;
int count = 0;
var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;
// Get all devices connected
var ret = idevice.idevice_get_device_list(out udids, ref count);
if (ret == iDeviceError.NoDevice)
{
// Not actually an error in our case
return;
}
ret.ThrowOnError();
// Variable to store UDID of
string foundUDID = "";
var nameOfDevice = "NameOfYourDevice";
// Get the device name
foreach (var udid in udids)
{
iDeviceHandle deviceHandle;
idevice.idevice_new(out deviceHandle, udid).ThrowOnError();
LockdownClientHandle lockdownHandle;
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle,
"Quamotion").ThrowOnError();
string deviceName;
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
deviceHandle.Dispose();
lockdownHandle.Dispose();
if(deviceName.equals(nameOfDevice)) //Check if name matches
{
foundUDID = udid;
break;
}
}
关于c# - 在 Connect C# 上获取 iphone 的 UDID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60402017/