提问人:Juraj Petrik 提问时间:3/13/2014 最后编辑:Nirav BhattJuraj Petrik 更新时间:12/10/2014 访问量:1955
FBDialogs presentShareDialogWithParams 回调处理程序永远不会被调用
FBDialogs presentShareDialogWithParams callback handler never gets called
问:
我正在使用FBDialogs在Facebook上分享。
facebook 共享工作正常,但处理程序从未被调用(我在第一行放了一个断点)
我的 SDK 是通过 CocoaPods 安装的
pod 'Facebook-iOS-SDK', '3.9.0'
这是代码,几乎是 Facebook 开发页面上的示例。我正在使用 ios7 在 iPod 上进行测试。
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
// Present the share dialog
[FBDialogs presentShareDialogWithParams:params
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
//never gets here
if(error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat: @"O comparilhando não foi bem sucedido. %@",error.description]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sucesso"
message:@"O compartilhando foi bem sucedido"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}}];
解决方案:
我的老板最后想通了。 我在我的 AppDelegate 中缺少此方法。没有它,Facebook 就无法将数据传回我的应用程序
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication: (NSString *)sourceApplication annotation:(id)annotation {
BOOL urlWasHandled = [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall *call) {
// incoming link processing goes here
}];
return urlWasHandled;
}
答:
0赞
Daxesh Nagar
5/23/2014
#1
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if ([[[[NSString stringWithFormat:@"%@",url] componentsSeparatedByString:@":"] objectAtIndex:0]isEqualToString:@"your FB ID"]) {
return [FBSession.activeSession handleOpenURL:url];
}
也许这对你有帮助。
评论