我有一个使用Facebook SDK的iOS应用程序。我从3.2升级到3.5.1部分是为了让我能够使用无摩擦的朋友请求。该过程适用于:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
message:[NSString stringWithFormat:@"I just posted an action - give me some points!"]
title:@"Get Points from your friends"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
NSLog(@"Request Sent.");
}
}}];
但是只要我添加好友缓存(从Facebook网站复制/粘贴):
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
FBFrictionlessRecipientCache *friendCache = [[FBFrictionlessRecipientCache alloc] init];
[friendCache prefetchAndCacheForSession:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
message:[NSString stringWithFormat:@"I just posted an action - give me some points!"]
title:@"Get points from your friends"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
NSLog(@"Request Sent.");
}
}}
friendCache:friendCache];
该应用程序将加载对话框但在FBWebDialogs.m上的[FBWebDialogInternalDelegate completeWithResult:url:error:]崩溃:93:当您点击X按钮取消对话框或尝试发送请求时。
我是否需要添加任何依赖项,以某种新方式启动会话,链接某些内容或其他任何他们未在https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.2-to-3.5/中告诉您的内容?
感谢。
答案 0 :(得分:8)
在这种情况下非常肯定是因为你没有在任何地方保留friendCache,而是在FBWebDialogs尝试使用它之前释放它(例如当对话框被解除时)。
如果你将friendCache移动到你的类中的ivar或属性而不是局部变量,这应该可行。
答案 1 :(得分:1)
我为项目启用 ARC 时遇到了同样的问题。
ARC FBFrictionlessRecipientCache *friendCache
在方法结束时自动发布,但当您按下窗口上的关闭/发送/取消按钮时,Facebook SDK需要它。
您必须将FBFrictionlessRecipientCache *friendCache
放在属性或类的开头以保留变量。
@interface className ()
{
FBFrictionlessRecipientCache *friendCache;
}