2

我需要一种方法来了解每个用户的唯一性,无论是针对 iPhone、Android 还是 Windows Phone 设备。如果没有通用的方法,我想知道保存电话号码是否合法(即合法)。

有人有这方面的经验吗?

4

7 回答 7

12

我不相信有,甚至不可能有跨平台的方式来做到这一点。每个设备都有自己的 SDK 平台和 API。

更新:对我之前的声明稍作更正,因为看起来PhoneGap可能能够为您提供跨平台方法。

电话间隙:

var deviceID = device.uuid;

请参阅:http ://docs.phonegap.com/phonegap_device_device.md.html

以下是您可以在每个平台上执行此操作的方法:

安卓:

android.telephony.getDeviceId()

请参阅:http: //developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId%28%29

苹果手机:

[[UIDevice currentDevice] uniqueIdentifier]

请参阅:http: //developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html

视窗电话 7:

DeviceExtendedProperties.GetValue("DeviceUniqueId")

请参阅:http: //msdn.microsoft.com/en-us/library/ff941122%28v=VS.92%29.aspx

黑莓:

FindDeviceForUserResult result=coreWebService.findDeviceForUser(userId, locale, true);
if (result.getFindDeviceForUserReturnStatus().getCode()!= FindDeviceForUserReturnStatusEnumType.SUCCESS)
{ 
       // handle any errors
}
if (result.getDevice() == null)
{ 
       // notify the user
}
int deviceID = result.getDevice().getDeviceId();

请参阅:http ://docs.blackberry.com/en/developers/deliverables/7283/Find_BlackBerry_devices_628863_11.jsp

于 2011-08-19T06:16:43.210 回答
2

如果您只关心移动设备,那么有一个叫做 IMEI numner 的东西。这应该是可访问的。法律含义我不确定。我想只要你不要太个人化(给一个人贴标签),这应该不是问题。

于 2011-08-19T06:12:08.830 回答
1

尝试获取 IMEI 号码。可能对你有用。

谢谢

于 2011-08-19T06:10:54.800 回答
1

在Android中,您可以通过这种方式获得

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
deviceid = telephonyManager.getDeviceId();
于 2011-08-19T06:16:13.777 回答
0

我不能代表 iPhone 或 Windows Phone 7,但要获得 Android 手机的唯一 ID,我建议查看这篇文章:

是否有唯一的 Android 设备 ID?

如前所述,它不是 100% 可靠的。

于 2011-08-19T06:12:33.710 回答
0

这就是我为 WindowsPhone 做的事情

 void checkGuid()
    {
            object uniqueID;
            DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueID);
            byte[] bID = (byte[])uniqueID;
            _clientID = Convert.ToBase64String(bID);
            Debug.WriteLine(_clientID);
            if (!IsolatedStorageSettings.ApplicationSettings.Contains("Guid"))
            {
                IsolatedStorageSettings.ApplicationSettings.Add("Guid", _clientID);
            }

    }

至于保留他们的电话号码,据我所知,微软会自动向用户提供协议,以响应他们检测到应用程序需要使用的内容,

您可以在用户启动应用程序时向他们提供某种 EULA,要求他们允许使用他们的电话号码

于 2011-08-19T18:43:01.517 回答
0

对于 iPhone 您将在 iPhone 中使用以下代码找到移动设备 ID。

 NSString *uniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];
 NSLog("UniqueIdentifier:-->%@",uniqueIdentifier);
于 2011-08-19T12:16:56.987 回答