2013-05-29 62 views
0

在我的應用程序中,我使用FBWebDialogs來發送應用程序請求Facebook的朋友,我做到了成功。我的問題是我不能處理FBWebDialog彈出窗口按鈕。在下面的代碼中,我可以檢測到X按鈕和取消按鈕,但是當我選擇發送按鈕時,它仍然給出日誌NSLog(@"User canceled request.");我使用facebook文檔中給出的代碼。我的錯誤是什麼?iphone開發:如何處理fbwebdialogs彈出按鈕

[FBWebDialogs 
     presentRequestsDialogModallyWithSession:nil 
     message:@"Learn how to make your iOS apps social." 
     title:nil 
     parameters:params 
     handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 
      if (error) { 
       // Error launching the dialog or sending the request. 
       NSLog(@"Error sending request."); 
      } else { 
       if (result == FBWebDialogResultDialogNotCompleted) { 
        // User clicked the "x" icon 
        NSLog(@"User canceled request."); 
       } else { 
        // Handle the send request callback 
        NSDictionary *urlParams = [self parseURLParams:[resultURL query]]; 
        if (![urlParams valueForKey:@"request"]) { 
         // User clicked the Cancel button 
         NSLog(@"User canceled request."); 
        } else { 
         // User clicked the Send button 
         NSString *requestID = [urlParams valueForKey:@"request"]; 
         NSLog(@"Request ID: %@", requestID); 
        } 
       } 
      } 
     }]; 

而且我有parseURLParams功能類似:

- (NSDictionary*)parseURLParams:(NSString *)query { 
    NSArray *pairs = [query componentsSeparatedByString:@"&"]; 
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; 
    for (NSString *pair in pairs) { 
     NSArray *kv = [pair componentsSeparatedByString:@"="]; 
     NSString *val = 
     [[kv objectAtIndex:1] 
     stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

     [params setObject:val forKey:[kv objectAtIndex:0]]; 
    } 
    return params; 
} 

回答

1

我發現,這是因爲在SDK 3.5,所以我從3.5 SDK升級到了3.5.1和錯誤的一個常見問題問題解決了。

相關問題