0

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. I would like to know what never changing property of an android device can I access programatically.

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 ? Thank you.

Kartik Watwani
  • 629
  • 8
  • 20

2 Answers2

0

For this purpose, you have to differentiate between devices.

For Android, you can use Device ID

For IOS, You can use vendor ID link.

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.

-(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;
}
Zeeshan Arif
  • 509
  • 5
  • 15
0

Im pretty sure these days you can use mac addresses, however if not have you tried IMEI, i have no idea how this would be done.

WMTS
  • 53
  • 1
  • 1
  • 12
  • https://stackoverflow.com/q/10831578/4961540 . This question says from marshmallow it is not allowed and what about dual sim phones each sim slot has different IMEI. – Kartik Watwani Sep 10 '17 at 14:05