I'm trying to send FB requests, but the FBWebDialog renders a UI that I have never seen before.. I'm not sure what I'm doing wrong. I've checked the usual suspects:
- facebook app settings
- Bundle Identifier
- FacebookDisplayName
- FacebookAppID
- URLTypes, URL Schemes
Code I'm using to send the request:
- (void)sendRequest {
NSError *error;
NSData *jsonData = [NSJSONSerialization
dataWithJSONObject:@{
@"social_karma": @"5",
@"badge_of_awesomeness": @"1",
@"request_action": @"1"}
options:0
error:&error];
if (!jsonData) {
NSLog(@"JSON error: %@", error);
return;
}
NSString *giftStr = [[NSString alloc]
initWithData:jsonData
encoding:NSUTF8StringEncoding];
NSMutableDictionary* params = [@{@"data" : giftStr} mutableCopy];
// Display the requests dialog
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:@"Please send me some Energy!"
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);
}
}
}
}];
}
The UI that I see:
Same UI, scrolled to the bottom:
The UI I expect to see (Same device using an FB Sample app):
Found the answer.. Facebook was responding with a different UI based on the User Agent that was being sent. The code I was working with modified the user agent to add some additional info for the server. Once I reset the user agent, the usual Facebook UI was shown.