skip to Main Content

This is my logic for implementing one device and one credential for my iOS Application according to the Client Demand

LOGIC

I am developing an iOS app which calls web-service for login and at that time i send login credentials to web server along with vendor identifier (identifierForVendor),to identify device uniquely for those credentials.So user can have only one device and one credential.

This identifier will then store in database of web server and also in device database.Next time when user opens application and will try to download data from web server firstly local identifierForVendor on users device will compare with identifier stored on web server.

CONCERN

I have a concern about whether the identifierForVendor will change or not if I download the application from Appstore and reinstall again from the Appstore by deleting the application?

This is the following scenario:

  1. Downloaded an App named “ABCDApp” from AppStore . Logged in with my credentials . I got an identifierForVendor for example: “1234”

  2. I deleted the app from my phone and again reinstalled the same app from AppStore
    Will I get the same vendor Id “ 1234 “ ? Or I will get different vendor Id if I reinstalled again from AppStore? Please note this vendor has only single App and no other App

I have from several links that it is not going to change if I UPDATE THE APP from the APPSTORE. The link which is follow is : Vendor ID does not changes when Updating app from Appstore. But what about reinstalling case ?

This is the code :

NSString *uuid = [[UIDevice currentDevice] identifierForVendor].UUIDString

My concern is : What if I uninstall and reinstall the application from Appstore again? Will it change ? If it changes how can I handle one device, one credential logic which I am planning to implement for my Application?

2

Answers


  1. From the documentation:

    The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

    So unless the user has another app from the same vendor installed, this id will change after deleting and reinstalling. In your case, where there is no other app by the same vendor, this means that the ID will change, and is therefore probably unsuited for your situation.

    One alternative could be to store a locally created UUID in the keychain, since keychain entries currently survive deletion and reinstallation of apps. However, this is an undocumented (mis)feature and may break at any time.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search