I am not sure how many people are familiar with the great todo sample app
however due to the minimalistic documentation approach it serves as a bible
to me right now understanding the joint work of Mobile and Sync Gateway.
However I would have a question about the flow and whether I just don't get
it or there is a logic issue within the app.
When looking at the sample I noticed that a profile document gets created
as part of the loginWithFacebook function. That works well when the user
truly doesn’t exist in the database but what happens when the user logs
back in and already has a profile on the remote database? For example I use
the sample app on my iPhone, sign up (profile document gets created and
synced) -> I also install the app on a a different device and log back in.
It is my current understanding that the profile documents gets created
again, is that correct? But it doesn’t seem right or how are the two
documents with the same document name handled? Do they update incrementally?
Asked a bit differently, our solution requires a profile document however
when the user logs in from a device, we want to check whether a profile
document already exists, sync first and then use it or create one if it
doesn’t exist already?
Can anyone shed some light on that? Am I missing something?
- (void)loginWithFacebookUserInfo:(NSDictionary *)info
> accessTokenData:(FBAccessTokenData *)tokenData { NSAssert(tokenData,
> @"Facebook Access Token Data is nil"); NSString *userId = [info
> objectForKey:@"email"]; NSString *name = [info objectForKey:@"name"]; [self
> setCurrentUserId:userId]; CBLDatabase *database = [self
> databaseForUser:userId]; [self setCurrentDatabase:database]; [self
> setGuestLoggedIn:NO]; Profile *profile = [Profile
> profileInDatabase:database forUserID:userId]; if (!profile) { profile =
> [[Profile alloc] initProfileInDatabase:self.database withName:name
> andUserID:userId]; NSError *error; if ([profile save:&error]) { [self
> migrateGuestDataToUser:profile]; } else { NSLog(@"Cannot create a new user
> profile : %@", [error description]); [self showMessage:@"Cannot create a
> new user profile" withTitle:@"Error"]; } } if (profile) { [self
> startReplicationWithFacebookAccessToken:tokenData.accessToken]; } }
>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/b08d9570-a600-41f1-bdc8-fbb1b719ff89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.