Facebook Login & Icenium

26 posts, 0 answers
  1. Robert Sprague
    Robert Sprague avatar
    7 posts
    Member since:
    Jan 2010

    Posted 03 Dec 2012 Link to this post

    I'm not sure how helpful this is, but I thought I'd share it.  I found a script online to help with a facebook login, and updated it to work in icenium using the ChildBrowser.  Also, a heads up... you have to uninstall your app completly from your android device and redeploy if you want to use the ChildBrowser plugin.  Found this little nugget a few posts back, but it is worth sharing.  I lost about 2 hours trying to troubleshoot that one.

    Please be forgiving, as I know that I'm not following traditional JS standards.

        function onPubFacebookBtn(){
            /* On Facebook Login */
            var myToken = window.localStorage.getItem("FBToken");
            if (myToken != null) {
                alert('This token already exists on this device.\n\n' + myToken);
            }
            else
            {
            var my_client_id  = "Your App ID",
            my_redirect_uri   = "http://www.facebook.com/connect/login_success.html",
            my_display        = "touch"
            var authorize_url  = "https://graph.facebook.com/oauth/authorize?";
            authorize_url += "client_id="+my_client_id;
            authorize_url += "&redirect_uri="+my_redirect_uri;
            authorize_url += "&display="+my_display;
            authorize_url += "&scope=publish_stream"
            cb = window.plugins.childBrowser
            cb.onLocationChange = function(loc){ facebookLocChanged(loc); };
            if(cb != null) {  cb.showWebPage(authorize_url); } 
            }
        }
    function ClearLocalStorage(){
        window.localStorage.clear();
        app.navigate("#tabstrip-home");
    }

        function facebookLocChanged(loc){
           /* Here we check if the url is the login success */
           if (/login_success/.test(loc)) {
               var fbCode = loc.match(/code=(.*)$/)[1]
               window.localStorage.setItem("FBToken",fbCode);
                window.plugins.childBrowser.close();
               app.navigate("#tabstrip-home");
           }
        }
  2. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 04 Dec 2012 Link to this post

    That's great. I might need that some time in the near future!

    However, a moderator might want to move this to the code snippets section.
  3. Jordan
    Admin
    Jordan avatar
    197 posts

    Posted 07 Dec 2012 Link to this post

    Thank you Robert and Jan-Dirk,

    great suggestion we will include similar one in our samples soon.

    Regards,
    Jordan
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  4. Hongyi
    Hongyi avatar
    1 posts
    Member since:
    Feb 2013

    Posted 15 Feb 2013 Link to this post

    Hi Jordan,

    Is there a formal Facebook login sample available now?

    Thank you,
    Hongyi
  5. Jordan
    Admin
    Jordan avatar
    197 posts

    Posted 21 Feb 2013 Link to this post

    Hi Hongyi, Jan-Dirk and Robert,

    We just added a sample mobile application with example of Facebook OAuth and Graph API usage - that demonstrates how to read from wall feed and post to it.

    You can clone from Sample Projects tab in your dashboard.
    In Mist it shall 
    appear in next 24h as sample-facebook-api. (Meanwhile you can clone it in Graphite or directly from from https://github.com/Icenium/sample-facebook-api)

    Note that sample uses Chiled Browser Cordova plugin so you need to on real device!


    Kind regards,
    Jordan
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  6. Владимир
    Владимир avatar
    6 posts
    Member since:
    Jun 2012

    Posted 08 Apr 2013 Link to this post

    Hello,
    I have a question: 
    https://github.com/Icenium/sample-facebook-api - does not work on device. Android v 2.3.3
    On iPAD2 - working without problem.
    Tested with cordova v.2.2.0 and v2.2.4
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Apr 2013 Link to this post

    Hello,

    We're aware of the problem and you can address it by modifying the code in jso.js like so:

    Api_default_storage.prototype.getTokens = function(provider) {
            // log("Get Tokens (" + provider+ ")");
            var tokens = JSON.parse(localStorage.getItem("tokens-" + provider));
            if (!tokens) tokens = [];
     
            log("Token received", tokens)
            return tokens;
        };

    should be:

    Api_default_storage.prototype.getTokens = function(provider) {
          // log("Get Tokens (" + provider+ ")");
          var localTokens = localStorage.getItem("tokens-" + provider),
              tokens = localTokens ? JSON.parse(localTokens) : [];
     
          log("Token received", tokens)
          return tokens;
      };

    We're going to fix this in our sample shortly.

    Regards,
    Steve
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Kendo UI Dojo.
  8. Владимир
    Владимир avatar
    6 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2013 Link to this post

    Hi, Steve!
    Thanks a lot! Application is working!
  9. Saravana
    Saravana avatar
    1 posts
    Member since:
    May 2013

    Posted 05 Jun 2013 Link to this post

    by using  'sample-Facebook-api' we can use the Facebook authentication for login but how can we logout from the app. is there any solution for the logout operation. thanks in advance
  10. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 05 Jun 2013 Link to this post

    Hello Saravana,

    Use "Revoke app permissions" button.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  11. Noel
    Noel avatar
    11 posts
    Member since:
    Jun 2013

    Posted 19 Jun 2013 Link to this post

    Thanks for making this sample facebook app. Right now, I am trying to modify the code. 

    I am trying to have a page that uses the "login button" to login with facebook and go to a new "view" after login is successful. I inserted window.location="#main" after child browser closes. It works fine. However, in my "#main" view, I am trying to post a picture to the user's facebook wall. The function cmdPost is not responding. In fact, I tried putting other buttons in "#main" view too. All of them are not responding. Do you know why this is the case?

    Thanks in advance!
  12. Chris Gillies
    Chris Gillies avatar
    384 posts
    Member since:
    May 2006

    Posted 20 Jun 2013 Link to this post

    Use the debugger in simulator to track down the problem. If you have iOS 6 + you can even debug on the actual device with the Web Inspector in the device tab (Graphite only). This post elaborates: http://www.icenium.com/blog/icenium-team-blog/2013/05/02/icenium-livesync---real-time-testing-and-debugging
  13. Христо
    Христо avatar
    13 posts
    Member since:
    Oct 2013

    Posted 13 Oct 2013 Link to this post

    Hello :) 

    The api is great :) But there is a small thing that I can't resolve. When I post some post to my wall, there is a "shared via Icenium Sample". How can I edit that ? 
    And the other case: when you logIn for a first time, the main message with the permissions shows the Icenium icon and the text again is Icenium Sample. How can I edit that? I want to brand my logo and name :) Is it posibble ? :)

    Thanks :) 

    Best Regards,
    Hristo Eftimov :) 
  14. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2013 Link to this post

    The "shared by Icenium Sample" can be changed in "postFacebook.js" by changing the value in "message" variable. The brand logo can probably be done by changing the "picture" variable.

    Good luck!
  15. Христо
    Христо avatar
    13 posts
    Member since:
    Oct 2013

    Posted 15 Oct 2013 Link to this post

    Thank you very much :) 

    I have another small problem :) How can I remove that Success message with the red warning ? I'm using inAppBrowserRef.close(); but that doesn't work iphone :) 
    Thank you :)
  16. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 18 Oct 2013 Link to this post

    Hello Христо,

    The "success message" is coming from Facebook API, not from Icenium or Cordova. Once you're authenticated successfully, the InAppBrowser is hidden. This works fine in our sample app, our suggestion is to compare the differences with your implementation.

    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  17. Leonard
    Leonard avatar
    17 posts
    Member since:
    Feb 2013

    Posted 20 Mar 2014 Link to this post

    How can I get user profile data and display user profile picture on my app? Thanks.
  18. Leonard
    Leonard avatar
    17 posts
    Member since:
    Feb 2013

    Posted 21 Mar 2014 in reply to Noel Link to this post

    Where should I put 'window.location...' in the script?
    Thanks.
  19. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 25 Mar 2014 Link to this post

    HI all,

    Please check our go to blog post about how to use the Facebook Cordova plugin in AppBuilder projects: http://tjvantoll.com/2014/02/06/connecting-appbuilder-projects-to-facebook/

    Hope this helps,
    Stefan Dobrev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

     
  20. Leonard
    Leonard avatar
    17 posts
    Member since:
    Feb 2013

    Posted 25 Mar 2014 in reply to Stefan Dobrev Link to this post

    Hi Stefan,

    I cannot create clone project from client-browser. Always having this alert:
    "An error occured: Failed to create the project in the service."

    Is this only for windows client?
  21. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 28 Mar 2014 Link to this post

    Hello Leonard,

    Thanks for contacting us.
    Currently the 'Clone repository' service is working as expected. For example I cloned https://github.com/tjvantoll/Facebook-Connect.git project successfully.

    In order to investigate your problem we will need the steps you are taking when cloning repository?
    Thanks.

    Regards,
    Zdravko
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

     
  22. Leonard
    Leonard avatar
    17 posts
    Member since:
    Feb 2013

    Posted 03 Apr 2014 in reply to Stefan Dobrev Link to this post

    I successfully install it on android. Login form appears, but having alert say that cannot connect to facebook.
    I closed the app, and try it again. This time everytime I click login, always go to facebook page with error message:

    "The page you requested, cannot be displayed right now. It may be temporarily unavailable....."

    But I was success to login with other facebook app. What cause the problem?

    Thanks :)
  23. Leonard
    Leonard avatar
    17 posts
    Member since:
    Feb 2013

    Posted 03 Apr 2014 in reply to Leonard Link to this post

    On iphone4, it only works when using release version (.ipa)
    Everytime I click login, it only show alert saying that the app need permission to access my data.
    I choose OK, the alert disappears. then nothing happens.
  24. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 08 Apr 2014 Link to this post

    Hello Leonard,

    Indeed the app has some difficulties to load the facebook login page on Android HTC 4.0.3 device, but works great on iOS and Nexus 5 Android 4.4.2. 
    What is your Android device specification?

    I suggest taking a look at our sample app which provides another Facebook login approach and it is frequently maintained.
    Thanks.

    Regards,
    Zdravko
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  25. Austin
    Austin avatar
    1 posts
    Member since:
    Apr 2015

    Posted 04 Jun 2015 in reply to Leonard Link to this post

    Hi Leonard, did you ever manage to get the project to clone?

     I've been getting that same error in the in-browser client and am wondering how to fix it.

  26. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 09 Jun 2015 Link to this post

    Hi Austin,

    Using the provided URL (https://github.com/tjvantoll/Facebook-Connect.git) from my previous reply in the in-browser client I was able to successfully clone the app as you can see in this demo.

    Please let us know the action you take on your side in order to reproduce the issue if it  still remains on your side. Any data like errors provided in the Developer Tools (F12) and a Fiddler log will be appreciated.
    The Fiddler log can be obtained using the steps below just consider sending it in a private ticket.

    1. Download Fiddler from here and install it.
    2. Run Fiddler and go to Tools -> Fiddler Options.
    3. On the HTTPS page, verify that Capture HTTPS Connects is enabled.
    4. Verify that Decrypt HTTPS traffic is enabled with the ...from all processes option and minimize Fiddler to tray.
    5. Try to reproduce the issue and then, continue to step 6.
    6. Open Fiddler again, go to File -> Save -> All Sessions, save the archive to disk (a SAZ file).
    7. Finally, send us the saz files attached to a private support ticket containing a reference to this thread.


    Regards,
    Zdravko
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top