{"id":1737,"date":"2022-08-30T15:19:01","date_gmt":"2022-08-30T15:19:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/29\/facebook-feed-dialog-returns-a-unhandled-javascript-including-post_id-that-crashes-ios-app-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:01","modified_gmt":"2022-08-30T15:19:01","slug":"facebook-feed-dialog-returns-a-unhandled-javascript-including-post_id-that-crashes-ios-app-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/facebook-feed-dialog-returns-a-unhandled-javascript-including-post_id-that-crashes-ios-app-collection-of-common-programming-errors\/","title":{"rendered":"Facebook Feed Dialog returns a unhandled JavaScript including post_id that crashes iOS app-Collection of common programming errors"},"content":{"rendered":"<p>I try to use Facebook&#8217;s Feed Dialog. According to the examples on the Facebook Developer&#8217;s web pages I coded two classes <em>MyAppModelClass<\/em> and <em>MyViewCntrl<\/em>, see below.<\/p>\n<p>Compilation runs without errors or warnings! And the iOS app hangs only the first time it is ran.<\/p>\n<p>When I call <em>[MyViewCntrl aMethod]<\/em> the <strong>first time<\/strong> &#8211; The user has to login with eMail and password &#8211; After login posting to the users wall can be edited<\/p>\n<p>&#8211; After clicking &#8220;share&#8221; button on the feed dialog I get a grey view displayed and the iOS app hangs.<\/p>\n<p>The view shows text that says:<\/p>\n<pre><code>\nwindow.location.href=\"fbconnect:\\\/\\\/success?\npost_id=_253268854729889#_=_\";\n\n<\/code><\/pre>\n<p>I thing the second number at post_id is a access token, but I am not sure.<\/p>\n<ul>\n<li>I <strong>do not<\/strong> get a NSLog from one of the FBDialofDelegate&#8217;s<br \/>\nmethods, (<em>[MyAppModelClass dialogDidComplete]<\/em>, <em>[MyAppModelClass dialogDidNotComplete]<\/em>, .) at console!<\/li>\n<li>The posting appears at the users wall<\/li>\n<\/ul>\n<p>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 <strong>do not<\/strong> get this javascript returned, everything works fine then.<\/p>\n<p>What can I do to handle, avoid or get rid of the javascript returned during the first run?<\/p>\n<p>See code outline below &#8230;<\/p>\n<p><strong>MyAppModelClass.h<\/strong><\/p>\n<pre><code>#import \"Facebook.h\"\n#import \"FBConnect.h\"\n#import \"FBDialog.h\"\n\n@interface MyAppModelClass :  NSObject   {\n\n@property (nonatomic, retain) Facebook* facebook;\n}\n<\/code><\/pre>\n<p><strong>MyAppModelClass.m<\/strong><\/p>\n<pre><code>#import \"MyAppModelClass.h\"\n\n@synthesize facebook;\n\n\n#pragma mark -\n#pragma mark FBDialogDelegate\n\n\n- (void) dialogDidComplete: (FBDialog*) dialog {\n   NSLog(@\".dialogDidComplete: %@\", dialog);\n}\n\n\n- (void) dialogCompleteWithUrl:(NSURL*) url {\n   NSLog(@\".dialogDidCompleteWithURL: %@\", url);\n}\n\n\n- (void) dialogDidNotComplete:(FBDialog*) dialog {\n   NSLog(@\".dialogDidNotComplete: %@\", dialog);\n}\n\n- (void)dialogDidNotCompleteWithUrl:(NSURL*) url {\n    NSLog(@\".dialogDidNotCompleteWithUrl: %@\", url);\n}\n\n\n- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError*) error{\n    NSLog(@\".didFailWithError: %@\", dialog);\n\n}\n<\/code><\/pre>\n<p><strong>MyViewCntrl.h<\/strong><\/p>\n<pre><code>#import \"MyAppModelClass.h\"\n\n- (void) aMethod;\n<\/code><\/pre>\n<p><strong>MyViewCntrl.m<\/strong><\/p>\n<pre><code>#import \"MyViewCntrl.h\"\n\n\n- (void) aMethod {\nNSMutableDictionary* myParameters = [[NSMutableDictionary alloc];\n          initWithObjectsAndKeys: @\"1234567\", @\"app_id\",  \n                                    @\"touch\", @\"display\",\n     @\"http:\/\/myWebSite.de\/pics\/AppIcon.jpg\", @\"picture\",\n                      @\"http:\/\/myWebSite.de\", @\"link\",  \n                         @\"It's my web site\", @\"caption\",\n               @\"Visit my personal web site\", @\"description\",\n                                    @\"false\", @\"show_error\", nil];\n\n[ptrMyAppModelClass facebook] dialog: @\"feed\"\n                           andParams: myParameters\n                         andDelegate: ptrMyAppModelClass];\n}\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-29 20:00:55. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I try to use Facebook&#8217;s Feed Dialog. According to the examples on the Facebook Developer&#8217;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 &#8211; The user [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1737","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1737"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1737\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}