Skip to main content

fbDidLogin not called


So, I've been messing around with the Facebook iOS SDK for a bit and as of the latest version I can't get the fbDidLogin method to be called. The login process works fine, with Safari used on the simulator and the Facebook app being used when running it on a device. However, after logging in I get transferred back to my app (as I should be) but as the fbDidLogin method hasn't been called, nothing has changed. As far as my app is concerned I'm not logged in. The demo app that is bundled with the SDK works fine. So I'm obviously doing something wrong, but I have no idea how to check what. I triple-checked all the methods used in the demo app against my own and as far as I can see everything looks the same. Any thoughts or ideas on how to debug this? Or has anyone had similar problems?



Thanks!


Source: Tips4allCCNA FINAL EXAM

Comments

  1. I encountered the same issue just now. I solved it by adding the following code into my application delegate:

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[controller facebook] handleOpenURL:url];
    }


    where controller is my UIViewController instance and facebook is my Facebook instance.

    You also need to register your app to handle your fb application's URL scheme (do that in you Info.plist).

    ReplyDelete
  2. One common mistake could be to not implement the following callback method in your main app delegate, but elsewhere. Implement this method in your class derived from UIApplicationDelegate. This is the entry point that iOS calls after the context switch to bring your application back to foreground.

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    // obtain facebook instance ref
    [ facebook handleOpenURL: url ];
    }


    If you have created FB application Id correctly and mapped the URL appropriately as defined in https://developers.facebook.com/docs/guides/mobile/#ios then it should work.

    ReplyDelete
  3. I solved the problem, If facebook is the object of your first viewcontroller that is being loaded by ur appdelegate, then you can use viewcontroller property of appdelegate to refer facebook object e.g

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
    {
    [ viewController.facebook handleOpenURL: url ];
    }

    ReplyDelete
  4. My cause for this was that I did not have the Facebook init in the ApDelegate using the correct delegate. I had it pointing to self, when it should be using the view controller where the user actually performed the login.

    From AppDelegate:

    facebook = [[Facebook alloc] initWithAppId:@"111111111111111" andDelegate:homeViewController];

    ReplyDelete
  5. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [ facebook handleOpenURL:url];
    }


    should write on AppDelegate.m so that it will accessible for whole app.

    please like it if it works

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.