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

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex