Facebook Feed Dialog returns a unhandled JavaScript including post_id that crashes iOS app

懵懂的女人 提交于 2019-12-20 03:12:18

问题


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:

<script type="text/javascript">
window.location.href="fbconnect:\/\/success?
post_id=<MyFbUserID>_253268854729889#_=_";
</script>

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 <FBDialogDelegate, FBSessionDelegate>  {

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

MyAppModelClass.m

#import "MyAppModelClass.h"

@synthesize facebook;


#pragma mark -
#pragma mark FBDialogDelegate


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


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


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

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


- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError*) error{
    NSLog(@"<FBDialogDelegate>.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];
}

来源:https://stackoverflow.com/questions/8236359/facebook-feed-dialog-returns-a-unhandled-javascript-including-post-id-that-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!