FBRequestConnection startForMeWithCompletionHandler - NSInvalidArgumentException
Posted
技术标签:
【中文标题】FBRequestConnection startForMeWithCompletionHandler - NSInvalidArgumentException【英文标题】: 【发布时间】:2014-08-01 14:48:30 【问题描述】:如果不引发异常,我似乎无法调用 FBRequestConnection startForMeWithCompletionHandler
。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use nil for keys or values on PFObject. Use NSNull for values.'
这曾经可以毫无问题地工作。但后来我删除了解析表中的“用户”对象。现在,每当我尝试登录时,都会在解析表中创建新用户,并且我会收到用户已登录的日志消息。但是当我想调用 FBRequestConnection 函数来检索用户的 facebook id 时,我会收到错误.
- (id) init
if (self == [super init])
[PFFacebookUtils initializeFacebook];
sharedHelper = self;
return self;
- (void) authenticateUserWithFacebook
NSArray *permissionsArray = @[@"user_relationships",@"user_friends",@"read_friendlists"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error)
if (!user)
if (!error)
NSLog(@"Uh oh. The user cancelled the Facebook login.");
else
NSLog(@"Uh oh. An error occurred: %@", error);
[[PFFacebookUtils session] closeAndClearTokenInformation];
[[PFFacebookUtils session] close];
[[FBSession activeSession] closeAndClearTokenInformation];
[[FBSession activeSession] close];
[FBSession setActiveSession:nil];
[PFUser logOut];
else if (user.isNew)
NSLog(@"User with facebook signed up and logged in!");
UIApplication *application = [UIApplication sharedApplication];
[application registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
[[PFUser currentUser] setObject:[result valueForKey:@"id"] forKey:kFbIdKey];
[[PFUser currentUser] setObject:[result valueForKey:@"name"] forKey:@"name"];
[[PFUser currentUser] saveInBackground];
];
else
NSLog(@"User with facebook logged in!");
UIApplication *application = [UIApplication sharedApplication];
[application registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
[[PFUser currentUser] setObject:[result valueForKey:@"id"] forKey:kFbIdKey];
[[PFUser currentUser] setObject:[result valueForKey:@"name"] forKey:@"name"];
[[PFUser currentUser] saveInBackground];
];
];
【问题讨论】:
【参考方案1】:我想我已经使用[FBSession renewSystemCredentials:]
解决了这个问题
以及删除并重新安装该应用程序。我认为我还删除了Installation
objects 的事实也与该问题有关。
【讨论】:
以上是关于FBRequestConnection startForMeWithCompletionHandler - NSInvalidArgumentException的主要内容,如果未能解决你的问题,请参考以下文章
FBRequestConnection startForCustomAudienceThirdPartyID 可以单独使用吗?
FBRequestConnection startForMyFriendsWithCompletionHandler 不带所有已安装应用程序的朋友 - iOS
FBRequestConnection startForCustomAudienceThirdPartyID:nil 适用于模拟器,而不适用于设备