简体   繁体   中英

Update users Email in Parse

I have PFUser object and it has firstName, lastName and Email.

When I try to update the user's email which is already exist, i am receiving error. But when fetch the email from [PFUser currentUser], it returns wrong email, how to overcome this. Below is the my code for it.

PFUser *user = [PFUser currentUser];
user[@"email"] = @"test@gmail.com"
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
       //UI refresh
    }];

I received the following error : the email address test@gmail.com has already been taken (Code: 203, Version: 1.7.4)

After this when fetching the email for current user

PFUser *user = [PFUser currentUser];
NSString *email = user[@"email"];
NSLog("email %@", email);

I received the following email "test@gmail.com" but which is wrong, which should be "tester@gmail.com".

FYI : I am also using parse offline store.

PFUser class has special property for email. You can change email doing:

PFUser *user = [PFUser currentUser];
user.email = @"test@gmail.com"

Try to refresh the PFUser objects by using

[[PFUser currentUser] fetchInBackgroundWithBlock];

Refer the retrieving objects in parse iOS documentation ( https://parse.com/docs/ios/guide#objects-retrieving-objects )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM