Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create your own UUID and then store it in the Keychain. Thus it persists even when your app gets uninstalled. In many cases it also persists even if the user migrates between devices (e.g. full backup and restore to another device). </p> <p>Effectively it becomes a unique <em>user identifier</em> as far as you're concerned. (even better than <em>device</em> identifier).</p> <p>Example:</p> <p>I am defining a custom method for creating a <code>UUID</code> as :</p> <pre><code>- (NSString *)createNewUUID { CFUUIDRef theUUID = CFUUIDCreate(NULL); CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID); return [(NSString *)string autorelease]; } </code></pre> <p>You can then store it in <code>KEYCHAIN</code> on the very first launch of your app. So that after first launch, we can simply use it from keychain, no need to regenerate it. The main reason for using Keychain to store is: When you set the <code>UUID</code> to the Keychain, it will persist even if the user completely uninstalls the App and then installs it again. . So, this is the permanent way of storing it, which means the key will be unique all the way.</p> <pre><code> #import "SSKeychain.h" #import &lt;Security/Security.h&gt; </code></pre> <p><strong>On applictaion launch include the following code :</strong></p> <pre><code> // getting the unique key (if present ) from keychain , assuming "your app identifier" as a key NSString *retrieveuuid = [SSKeychain passwordForService:@"your app identifier" account:@"user"]; if (retrieveuuid == nil) { // if this is the first time app lunching , create key for device NSString *uuid = [self createNewUUID]; // save newly created key to Keychain [SSKeychain setPassword:uuid forService:@"your app identifier" account:@"user"]; // this is the one time process } </code></pre> <p>Download SSKeychain.m and .h file from <a href="https://github.com/samsoffes/sskeychain" rel="noreferrer">sskeychain</a> and Drag SSKeychain.m and .h file to your project and add "Security.framework" to your project. To use UUID afterwards simply use :</p> <pre><code>NSString *retrieveuuid = [SSKeychain passwordForService:@"your app identifier" account:@"user"]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload