gpt4 book ai didi

ios - 解析 Facebook Dialog Delegate 方法未被调用

转载 作者:行者123 更新时间:2023-12-01 19:13:48 25 4
gpt4 key购买 nike

我正在使用 Parse SDK 来实现 Facebook apprequests我的应用程序中的对话框。出于所有意图和目的,它只是包装了 Facebook SDK,在 Facebook 方法前加上 PF_ .

我使用这段代码来准备和引发对话框:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"I just challenged you to a game!"], @"message",
[friendIds componentsJoinedByString:@"," ], @"to",
nil];

PF_FBSession *session = [PFFacebookUtils session];
PF_Facebook *facebook = [[PF_Facebook alloc] initWithAppId:session.appID andDelegate:nil];

facebook.accessToken = session.accessToken;
facebook.expirationDate = session.expirationDate;

[facebook dialog:@"apprequests" andParams:params andDelegate:self];

这很好用,我得到了对话框,我可以邀请 friend 玩这个应用程序。

问题是没有调用委托(delegate)方法,即使我已将 View Controller 设置为 PF_FBDialogDelegate :
@interface ChallengeFriendsViewController : UIViewController <UITableViewDelegate, PF_FBDialogDelegate> {
NSArray *facebookFriends;
NSMutableArray *selectedFriends;
}

这些是我正在谈论的一些委托(delegate)方法:
- (void)dialog:(PF_FBDialog *)dialog didFailWithError:(NSError *)error {
NSLog(@"Error in Dialog: %@", error);
}

- (void)dialogDidNotCompleteWithUrl:(NSURL *)url {
NSLog(@"Failure on Facebook server side");
}

- (void)dialogCompleteWithUrl:(NSURL *)url {
NSLog(@"Did complete with URL");
[self.navigationController popViewControllerAnimated:YES];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}

- (void)dialogDidNotComplete:(PF_FBDialog *)dialog {
NSLog(@"Cancelled");
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}

如果不调用这些方法,我真的无法以直观的方式处理共享。我很困惑为什么不叫他们,觉得我已经尝试了一切。任何指向我哪里出错的指针?

最佳答案

在您的代码中,您有

PF_Facebook *facebook = [[PF_Facebook alloc] initWithAppId:session.appID andDelegate:nil];

由于您设置了一个 nil 委托(delegate),因此我希望永远不会调用委托(delegate)方法,正如您所描述的那样。

你能把这个改成
PF_Facebook *facebook = [[PF_Facebook alloc] initWithAppId:session.appID andDelegate:self];

那是假设您将委托(delegate)方法放在同一个类中。

关于ios - 解析 Facebook Dialog Delegate 方法未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14611208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com