现在与android 10更新的权限和安全性,我们不能访问用户的设备ID和IMEI号码,但我想要一些设备的唯一ID,以便我们可以跟踪用户。
要求是我们想要/限制一部手机的一次登录
由于序列号和IMEI号已被Android 10及以后版本弃用,因此我们可以找到具有READ_PRIVILEGED_PHONE_状态的唯一标识符的Android id。
更多信息请点击下面的链接。https://developer.android.com/training/articles/user-data-ids
Android引入了一个新的id来唯一地标识一个设备,称为Advertision_id。您可以从应用程序类onCreate方法中的以下代码实现中获取该id。
/** Retrieve the Android Advertising Id
*
* The device must be KitKat (4.4)+
* This method must be invoked from a background thread.
*
* */
public static synchronized String getAdId (Context context) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
return null;
}
AdvertisingIdClient.Info idInfo = null;
try {
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(context);
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String advertId = null;
try{
advertId = idInfo.getId();
}catch (NullPointerException e){
e.printStackTrace();
}
return advertId;
}
为了科特林
fun getAdId() {
//Background Task
AsyncTask.execute {
var adInfo: AdvertisingIdClient.Info? = null
try {
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext)
if(adInfo!=null){
val id = adInfo!!.getId()
val isLAT = adInfo!!.isLimitAdTrackingEnabled()
PersistData.setStringData(applicationContext, AppConstant.advertId, id)
val advertId = PersistData.getStringData(applicationContext, AppConstant.advertId)
}
} catch (e: IOException) {
// Unrecoverable error connecting to Google Play services (e.g.,
// the old version of the service doesn't support getting AdvertisingId).
} catch (e: GooglePlayServicesAvailabilityException) {
// Encountered a recoverable error connecting to Google Play services.
} catch (e: GooglePlayServicesNotAvailableException) {
// Google Play services is not available entirely.
}
}
}
Android 10限制开发者访问IMEI号码。
您可以通过获取软件ID来获得替代解决方案。您可以使用软件ID作为唯一的ID。请在下面找到我在应用程序中使用的代码。
public static String getDeviceId(Context context) {
String deviceId;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
deviceId = Settings.Secure.getString(
context.getContentResolver(),
Settings.Secure.ANDROID_ID);
} else {
final TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (mTelephony.getDeviceId() != null) {
deviceId = mTelephony.getDeviceId();
} else {
deviceId = Settings.Secure.getString(
context.getContentResolver(),
Settings.Secure.ANDROID_ID);
}
}
return deviceId;
}
问题内容: 如何在Swift中获取设备的唯一ID? 我需要一个ID才能在数据库中使用,并作为我的社交应用程序中Web服务的API密钥。可以跟踪该设备日常使用并将其查询限制在数据库中的东西。 谢谢! 问题答案: 您可以使用此(快速3): 对于旧版本: 或者如果您想要一个字符串: 用户卸载应用后,不再有一种唯一标识设备的方法。该文档说: 当该应用程序(或同一供应商的另一个应用程序)安装在iOS设备上时
在Android中,我们有,<代码>设置。保护ANDROID\u ID。我不知道iOS的等效版本。在flutter中是否有一个flutter插件或一种方法可以为Android和IOS获取唯一的设备id?
我想在我的应用程序中获得唯一的设备id。但据谷歌文件称,Android10增加了对不可重置标识符的限制。 我不想要随机的id。我想得到唯一的id,这样我就可以识别我的应用编程接口被击中的设备。通过它,我可以管理我的会话。除了Secure.android之外还有另一个唯一的id_id这对Android来说是唯一的吗?或者有什么方法可以访问Android10中的Secure.android_id。
本文向大家介绍iOS获取设备唯一标识的8种方法,包括了iOS获取设备唯一标识的8种方法的使用技巧和注意事项,需要的朋友参考一下 8种iOS获取设备唯一标识的方法,希望对大家有用。 UDID UDID(Unique Device Identifier),iOS 设备的唯一识别码,是一个40位十六进制序列(越狱的设备通过某些工具可以改变设备的 UDID),移动网络可以利用 UDID 来识别移动设备。
我们可以从adb shell获取连接到android设备的设备列表吗?
通过 id 获取 device 信息 参数说明 字段 类型 必须? 说明 deviceId String 是 设备Id 接口定义 Swift: let device = RokidMobileSDK.device.getDevice(deviceId: String) -> RKDevice? Objc: RKDevice * device = [RokidMobileSDK.device ge