How to preserve identifierForVendor in ios after uninstalling ios app on device?
You may keep it in KeyChain
-(NSString *)getUniqueDeviceIdentifierAsString
{
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];
if (strApplicationUUID == nil)
{
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];
}
return strApplicationUUID;
}
Will identifierForVendor change if I install and reinstall an application from the AppStore?
Yes it changes all the time for each and every installation. If you want to send same UUID to service all the time you have save the UUID in KeyChainStore provided the link below:
enter link description here
I have solved this problem with the help of the link provided above like this.
NSString* identifier;
UICKeyChainStore *keychainStore = [UICKeyChainStore keyChainStore];
if(keychainStore[@"UDID"])
{
identifier=keychainStore[@"UDID"];
NSLog(@"output is : %@", identifier);
[SessionManager saveUDID:identifier];
}
else
{
identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; // IOS 6+
NSLog(@"output is : %@", identifier);
keychainStore[@"UDID"] = identifier;
[SessionManager saveUDID:identifier];
}
+(void)saveUDID:(NSString*)udid
{
[[NSUserDefaults standardUserDefaults] setObject:udid forKey:@"UDID"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString*)getUDID
{
NSString *udid = [[NSUserDefaults standardUserDefaults]
stringForKey:@"UDID"];
return udid;
}
// logout from app
-(void)logOutFromApp
{
UIApplication*app=[UIApplication sharedApplication];
NSDictionary*dic;
AppDelegate *appDel = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDel application:app didFinishLaunchingWithOptions:dic];
[self.delegate logoutFired];
}
I hope it will help you. Happy Coding.
Identifier for Vendor is gettnig changed everyTime app is reinstalled
This correct behavior as described in UIDevice documentation.
If you want to store some identifier that is persisted when the app is uninstalled you should save a unique value in the keychain.
Just be aware that even these will not be 100% stored, the user can delete then if he/she has knowledge of the keychain or the device is wiped.
identifierForVendor changes on reinstall
It's a known bug. It seems like Apple made an update to AppStore that causes this new behavior for identifierForVendor around the 28:th May. If you search in the App Developer forum, there are other developers reporting the same problem.
The signature gc from Apple have replied on the issue with the following answer:
"Please file bug reports on this at https://developer.apple.com/bug-reporting>. We're aware of this issue and are investigating. There's no known workaround at this time."
is it possible for iOS identifierForVendor to be duplicated?
Teoretically yes, but for practical applications you shouldn’t need to worry about this.
identifierForVendor
is of UUID
type - this wiki page has a section on collision probability for UUIDs in general, not only on iOS. The short of it is that in order to have 50% chance of collision you’d need to generate ~2.71*10^18
identifiers. And thats
equivalent to generating 1 billion UUIDs per second for about 85 years. A file containing this many UUIDs, at 16 bytes per UUID, would be about 45 exabytes.
Also, I wouldn’t say that its an „issue”, but rather a decision choice made by Apple - in the documentation they clearly state that
The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
device identifierForVendor UUIDString different for release and test on same device
You need to persist it yourself as it will change when a user uninstalls/re installs the app. So in your case when you download it from the Appstore its a new install and the identifier will have changed
How to preserve identifierForVendor in ios after uninstalling ios app on device?
Related Topics
How to Detect When Someone Shakes an Iphone
Difference Between 'Yyyy' and 'Yyyy' in Nsdateformatter
How to Load an Http Url With App Transport Security Enabled in iOS 9
How to Embed a Custom Font in an Iphone Application
Create Singleton Using Gcd'S Dispatch_Once in Objective-C
How to Return Value from Alamofire
Adjust Uilabel Height Depending on the Text
How to Do Base64 Encoding on Ios
Looking to Understand the iOS Uiviewcontroller Lifecycle
How to Link to Apps on the App Store
Converting String to Int With Swift
Undefined Symbols For Architecture Arm64
Will iOS Launch My App into the Background If It Was Force-Quit by the User
Launch an App from Within Another (Iphone)
Getting a Thumbnail from a Video Url or Data in Ios
How to Create a Button Programmatically
Swift Compiler Error: "Expression Too Complex" on a String Concatenation