简体   繁体   English

我怎么知道我的应用程序以前已经安装在手机上?

[英]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.

相关问题 我如何知道用户是否已安装并打开我的应用程序? - How do I know if a user has my app installed and opened? 我怎么知道我的应用程序已被删除? - How can I know if my app is removed? 我可以从Playstore知道已安装我的应用程序的用户的电子邮件ID吗 - Can i know email id's of user who have installed my app from playstore 我需要知道可以为我的应用程序放置什么内容,才能将其安装在外部存储器上 - I need to know what to put for my app can be installed on external memory 如何确保我的应用程序无法安装在棉花糖上 - How can I ensure my app can not be installed on Marshmallow 我在手机中安装了我的应用程序而没有构建错误,但应用程序在我的手机中以白屏运行 - i installed my app without build error in my phone but app run with white screen in my phone 为什么我在手机上看不到已安装的android应用程序? - Why i can not see my installed android application on my phone? 我怎么知道我最新版本的Android应用已更新为所有安装的用户? - How would i know my latest version of Android app has been updated to all installed users? 如何确定我的应用程序是否安装在 SD 卡上 - How can i find out if my app is installed on SD card 我怎么知道我的android手机“通讯录APP”支持哪个版本的名片? - How do I know which version of vCard my android phone "Contacts APP" support?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM