【问题标题】:Is there a programmatic way to get a mobile device's unique identifier?有没有一种程序化的方式来获取移动设备的唯一标识符?
【发布时间】:2011-08-19 06:04:31
【问题描述】:

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

有人有这方面的经验吗?

【问题讨论】:

    标签: iphone android windows-phone-7 uniqueidentifier unique-key


    【解决方案1】:

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

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

    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

    iPhone:

    [[UIDevice currentDevice] uniqueIdentifier]
    

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

    Windows Phone 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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

        谢谢

        【讨论】:

          【解决方案4】:

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

          TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
          deviceid = telephonyManager.getDeviceId();
          

          【讨论】:

            【解决方案5】:

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

            Is there a unique Android device ID?

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

            【讨论】:

              【解决方案6】:

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

               NSString *uniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];
               NSLog("UniqueIdentifier:-->%@",uniqueIdentifier);
              

              【讨论】:

                【解决方案7】:

                这就是我在 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);
                            }
                
                    }
                

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

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

                【讨论】:

                  猜你喜欢
                  • 2012-03-13
                  • 1970-01-01
                  • 2013-06-30
                  • 2012-06-01
                  • 1970-01-01
                  • 2020-02-29
                  • 2013-09-19
                  • 2017-10-24
                  • 1970-01-01
                  相关资源
                  最近更新 更多