title: AWS Cognito identityId changing for anonymous/guest users
body: <p>I was happily using Cognito Sync with my pre-release app (iOS/Objective-C), with Facebook login. However, upon submitting for Apple App Store review, I was asked to remove Facebook login. I thought it would be straightforward - just changed the unauth role policies to match the auth user and bypassed anything to do with Facebook authentication.</p>
  
  <p>However, now I am finding that identityId is changing between sessions. It is behaving like a session ID. This is a major headache because my app uses identityId as the hash key in DynamoDB. So, for example, a DynamoDB search for recent activities by current user shows only the current session's history, not ALL history as intended.</p>
  
  <p>I was using the sample app's code to obtain identityId - it seems to be getting assigned correctly. Based on the sample's AWSIdentityManager.m, following is part of the AppDelegate.m inside <code>didFinishLaunchingWithOptions</code>:</p>
  
  <pre><code>AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AMAZON_COGNITO_REGION
                                                                                                  identityPoolId:AMAZON_COGNITO_IDENTITY_POOL_ID];
  AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AMAZON_COGNITO_REGION
                                                                       credentialsProvider:credentialsProvider];
  AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
  
  [[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task) {
      if (task.error) {
          NSLog(@"Error: Could not obtain identity id: %@", task.error);
      }
      else {
          // the task result will contain the identity id
          NSString *cognitoId = task.result;
          NSLog(@"Got the identity ID as %@", cognitoId);
          // Don't change the ID
          NSString *oldId = [[NSUserDefaults standardUserDefaults] objectForKey:NSUD_COGNITO_ID];
          if (!oldId) {
              [[NSUserDefaults standardUserDefaults] setObject:cognitoId forKey:NSUD_COGNITO_ID];
              [[NSUserDefaults standardUserDefaults] synchronize];
          } else {
              NSLog(@"Old = %@, New = %@, Keeping old", oldId, cognitoId);
          }
      }
      return nil;
  }];
  </code></pre>
  
  <p>I keep getting the message that old and new identities are not the same. Also, when I check in Cognito Sync, the old identities can no longer be found. </p>
  
  <p>Now that there is no Facebook SignIn provider in use, how do I ensure that the identityId does not change across sessions etc? Can someone shed a light on why this is changing? I have confirmed that I am not clearing the keychain anywhere in the code.</p>