views:

520

answers:

2

When user hits the Cancel button in the FBStreamDialog, which inherits from FBDialog, I am having trouble differentiating it from when user clicks on the Publish button. Seems that the callback FBDialog dismissWithSuccess is always passed with the status:NO regardless of which button is clicked. What am I doing wrong? Thanks!

Here's the class that handles all the FBConnect in my app:

@interface SocialMediaViewController : UIViewController <FBSessionDelegate, FBRequestDelegate, FBDialogDelegate> {...

Here's how I instantiated the login.

FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:self.fbSession] autorelease]; 
dialog.delegate = self;
[dialog show];

Here's how I instantiated the FBStreamDialog.

FBStreamDialog* dialog = [[FBStreamDialog alloc] init]; 
dialog.delegate = self; 
dialog.userMessagePrompt = @"Enter additional comment:"; 
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"My name string %@\"," "\"href\":\"http://xyz.com/\"," "\"caption\":\"placeholder-%@\",\"description\":\"%@\"," "\"properties\":{\"More like this\":{\"text\":\"XYZ website\",\"href\":\"http://XYZ.com/\"}}}", self.curReview.businessName, self.curReview.reviewType, self.curReview.reviewDetail]; 
[dialog show];
A: 

Hi there - does anyone out there have Facebook Connect experience on iPhone and has come across and solved this issue before? Appreciate any hint! This is preventing me from going live with a client app. Thanks...

twinkle
+1  A: 

Add the following as the first line in FBDialog.m / webViewDidFinishLoad :

[_webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('cancel').onclick = function onclick(event) { window.location.href = 'fbconnect:cancel'; }"];

Bear in mind that Facebook doesn't let you "punish" users for canceling :-)

Erich