iosamazon-web-servicesamazon-cognitoamazon-cognito-facebook

How to check if user login to AWS Cognito for the first time?


I'm using mobile hub and Amazon Cognito to authenticate user by using Facebook provider. Once use login with Facebook I need to check if this is first time login to the app or not. If it is first time I need to get some information and if it is already sign-up to the app I need to get some information related to the user from dynamoDB. I was wondering what would be the best way to find out if user login to the app for the first time.

#import <AWSMobileHubHelper/AWSMobileHubHelper.h>

@implementation UserIdentityAccess

- (NSString *)getUserIdentity {
    return [AWSIdentityManager defaultIdentityManager].identityId;
}

Solution

  • If you're already using Dynamo to store user metadata, you could potentially use that to store a flag on whether or not identity id x has been seen before.

    Alternatively, Cognito Sync could be used here. You could put a record in a dataset that tracks if it's already been seen, then just check if it exists. One benefit this gives is it stores it against the identity id for you, so you don't have to deal with identity id to data mapping yourself. More information on Cognito sync is available here.