[英]How can I know my app was previously installed on a phone?
I am trying to make an app which allows only single account per device. 我正在尝试制作一个仅允许每个设备使用一个帐户的应用程序。 Now what I am trying to know is a property of a phone which never changes.
现在,我想知道的是手机的特性,它永远不会改变。 At first I thought I could save MAC address of a device in my database but I read in one of the question on SO that know in android when we try to access MAC address programatically we get a constant that is same for every device.
起初我以为可以将设备的MAC地址保存在数据库中,但我读了一个关于SO的问题,当我们尝试以编程方式访问MAC地址时,在android中就知道了,我们得到的常数对于每个设备都是相同的。 I would like to know what never changing property of an android device can I access programatically.
我想知道可以通过编程方式访问android设备的永不更改的属性。
Also in future I would like to develop that app for iOS, is there same non changing property of iOS phone that I can access programatically ? 同样在将来,我想为iOS开发该应用程序,我可以通过编程方式访问iOS手机的不变属性吗? Thank you.
谢谢。
For this purpose, you have to differentiate between devices. 为此,您必须区分设备。
For Android, you can use Device ID 对于Android,您可以使用设备ID
For IOS, You can use vendor ID link . 对于IOS,您可以使用供应商ID 链接 。
For IOS : When your app deleted and reinstalled then vendor ID changes so it is better to store your vendor id in keychain using below code. 对于IOS:删除并重新安装您的应用后,供应商ID会发生变化,因此最好使用以下代码将供应商ID存储在钥匙串中。
-(NSString *)getUniqueDeviceIdentifier
{
NSString *yourAppName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *applicationUUIDStr = [SSKeychain passwordForService:appName account:@“Your_App_Name”];
if (applicationUUIDStr == nil)
{
applicationUUIDStr = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:@"Your_App_Name"];
}
return applicationUUIDStr;
}
我很确定这些天你可以使用mac地址,但是如果没有尝试过IMEI,我不知道该怎么做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.