我正在使用Parse,我想显示从Parse获取的电子邮件,并在Parse的列中显示。 first_name
,last_name
,id
等所有内容都可以。但是当我尝试设置prop.email
时,它找不到任何属性。如果我在该地方执行相同的操作(在代码中标记),它会发现我没有任何问题的电子邮件属性。
我的意思是这行代码:
[[PFUser currentUser] setObject:prop.id forKey:@"fbid"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.first_name forKey:@"firstname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.last_name forKey:@"lastname"];
[[PFUser currentUser] saveInBackground];
//This one doesn`t find property email
[[PFUser currentUser] setObject:prop.email forKey:@"email"];
[[PFUser currentUser] saveInBackground];
FB的其余部分连接`code
{
NSArray *permissionsArray = @[@"email"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
// Was login successful ?
if (!user) {
if (!error) {
NSLog(@"The user cancelled the Facebook login.");
}else {
NSLog(@"An error occurred: %@", error.localizedDescription);
}
// Callback - login failed
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:NO];
}
}else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary<FBGraphUser> *prop = (NSDictionary<FBGraphUser> *)result;
[[PFUser currentUser] setObject:prop.id forKey:@"fbid"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.first_name forKey:@"firstname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.last_name forKey:@"lastname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.email forKey:@"email"];
[[PFUser currentUser] saveInBackground];
}else {
NSLog(@"User logged in through Facebook!");
NSLog(@"Welcome Screen I am %@", [[PFUser currentUser] username]);
}
}];
}
else {
//HERE
NSLog(@"Error getting the FB username %@", [error description]);
}
[[PFUser currentUser] saveInBackground];
// Callback - login successful
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:YES];
}
}];
}
答案 0 :(得分:0)
您的代码会生成编译错误,因为email
协议中未定义PFSignUpViewController
。因此,您需要找到一种不同的方式来从Facebook获取用户的电子邮件。
如果您正在使用{{1}},然后再关联该帐户,请确保该用户在该时间点输入电子邮件。