I have an iOS app that uses the Facebook SDK. I upgraded from 3.2 to 3.5.1 in part to allow me to use frictionless friend requests. The process works fine with:
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.");
}
}}];
But as soon as I add the friend cache (copy / pasted from the Facebook website):
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];
The app will load the dialog but crash on [FBWebDialogInternalDelegate completeWithResult:url:error:] at FBWebDialogs.m:93: when you either tap the X button to cancel the dialog or try to send a request.
Do I need to add any dependancies, start sessions in some new way, link something or anything else that they don't tell you in https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.2-to-3.5/?
Thanks.
Pretty sure in this case it's because you're not retaining the friendCache anywhere, and it gets released before the FBWebDialogs tries to use it (such as when the dialog is dismissed).
If you move the friendCache into an ivar or property in your class instead of a local variable, this should work.