Reputation: 1134
In my app I use FBWebDialogs to sen app request to facebook friends and I do it successfullty. My problem is I cant handle FBWebDialogs pop up windows button. In the code below I can detect X button and cancel button but when I select send button it still gives the log NSLog(@"User canceled request.");
I am using the codes exactly given in the facebook documentation. What is my mistake?
[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);
}
}
}
}];
And I have parseURLParams function like that:
- (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;
}
Upvotes: 0
Views: 1540
Reputation: 1134
I found that it is a common problem because of a bug in SDK 3.5 so I updated the sdk from 3.5 to 3.5.1 and the problem solved.
Upvotes: 1