Facebook iOS SDK 3.5.1好友请求对话框在关闭时崩溃

Mar*_*tin 2 facebook ios facebook-ios-sdk

我有一个使用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.");
                                                          }
                                                      }}];
Run Code Online (Sandbox Code Playgroud)

但是只要我添加好友缓存(从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];
Run Code Online (Sandbox Code Playgroud)

该应用程序将加载对话框但在FBWebDialogs.m上的[FBWebDialogInternalDelegate completeWithResult:url:error:]崩溃:93:当您点击X按钮取消对话框或尝试发送请求时.

我是否需要添加任何依赖项,以某种新方式启动会话,链接某些内容或其他任何他们未告诉您的内容,请访问https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.2-到-3.5 /

谢谢.

Min*_* Li 8

非常肯定在这种情况下,因为你没有在任何地方保留friendCache,并且在FBWebDialogs尝试使用它之前它被释放(例如当对话框被解除时).

如果将friendCache移动到类中的ivar或属性而不是局部变量,这应该可行.