Facebook Feed Dialog returns a unhandled JavaScript including post_id that crashes iOS app-Collection of common programming errors

I try to use Facebook’s Feed Dialog. According to the examples on the Facebook Developer’s web pages I coded two classes MyAppModelClass and MyViewCntrl, see below.

Compilation runs without errors or warnings! And the iOS app hangs only the first time it is ran.

When I call [MyViewCntrl aMethod] the first time – The user has to login with eMail and password – After login posting to the users wall can be edited

– After clicking “share” button on the feed dialog I get a grey view displayed and the iOS app hangs.

The view shows text that says:


window.location.href="fbconnect:\/\/success?
post_id=_253268854729889#_=_";

I thing the second number at post_id is a access token, but I am not sure.

  • I do not get a NSLog from one of the FBDialofDelegate’s
    methods, ([MyAppModelClass dialogDidComplete], [MyAppModelClass dialogDidNotComplete], .) at console!
  • The posting appears at the users wall

If I stop the iOS app in the iphone simulator (home button) and i Xcode (stop button) and then restart the app on the iPhone simulator I do not get asked for authentication. And I do not get this javascript returned, everything works fine then.

What can I do to handle, avoid or get rid of the javascript returned during the first run?

See code outline below …

MyAppModelClass.h

#import "Facebook.h"
#import "FBConnect.h"
#import "FBDialog.h"

@interface MyAppModelClass :  NSObject   {

@property (nonatomic, retain) Facebook* facebook;
}

MyAppModelClass.m

#import "MyAppModelClass.h"

@synthesize facebook;


#pragma mark -
#pragma mark FBDialogDelegate


- (void) dialogDidComplete: (FBDialog*) dialog {
   NSLog(@".dialogDidComplete: %@", dialog);
}


- (void) dialogCompleteWithUrl:(NSURL*) url {
   NSLog(@".dialogDidCompleteWithURL: %@", url);
}


- (void) dialogDidNotComplete:(FBDialog*) dialog {
   NSLog(@".dialogDidNotComplete: %@", dialog);
}

- (void)dialogDidNotCompleteWithUrl:(NSURL*) url {
    NSLog(@".dialogDidNotCompleteWithUrl: %@", url);
}


- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError*) error{
    NSLog(@".didFailWithError: %@", dialog);

}

MyViewCntrl.h

#import "MyAppModelClass.h"

- (void) aMethod;

MyViewCntrl.m

#import "MyViewCntrl.h"


- (void) aMethod {
NSMutableDictionary* myParameters = [[NSMutableDictionary alloc];
          initWithObjectsAndKeys: @"1234567", @"app_id",  
                                    @"touch", @"display",
     @"http://myWebSite.de/pics/AppIcon.jpg", @"picture",
                      @"http://myWebSite.de", @"link",  
                         @"It's my web site", @"caption",
               @"Visit my personal web site", @"description",
                                    @"false", @"show_error", nil];

[ptrMyAppModelClass facebook] dialog: @"feed"
                           andParams: myParameters
                         andDelegate: ptrMyAppModelClass];
}