This is a migrated thread and some comments may be shown as answers.

Facebook Login & Icenium

25 Answers 370 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert Sprague
Top achievements
Rank 1
Robert Sprague asked on 04 Dec 2012, 03:59 AM
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");
       }
    }

25 Answers, 1 is accepted

Sort by
0
Jan-Dirk
Top achievements
Rank 1
answered on 04 Dec 2012, 10:26 AM
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.
0
Jordan
Telerik team
answered on 07 Dec 2012, 07:58 AM
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.
0
Hongyi
Top achievements
Rank 1
answered on 15 Feb 2013, 10:32 PM
Hi Jordan,

Is there a formal Facebook login sample available now?

Thank you,
Hongyi
0
Jordan
Telerik team
answered on 21 Feb 2013, 09:45 AM
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.
0
Владимир
Top achievements
Rank 1
answered on 08 Apr 2013, 09:06 AM
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
0
Steve
Telerik team
answered on 09 Apr 2013, 03:39 PM
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.
0
Владимир
Top achievements
Rank 1
answered on 09 Apr 2013, 06:00 PM
Hi, Steve!
Thanks a lot! Application is working!
0
Saravana
Top achievements
Rank 1
answered on 05 Jun 2013, 12:49 PM
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
0
Steve
Telerik team
answered on 05 Jun 2013, 12:53 PM
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.
0
Noel
Top achievements
Rank 1
answered on 20 Jun 2013, 01:18 AM
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!
0
Chris Gillies
Top achievements
Rank 1
answered on 20 Jun 2013, 02:47 PM
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
0
Христо
Top achievements
Rank 1
answered on 13 Oct 2013, 10:33 AM
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 :) 
0
Jan-Dirk
Top achievements
Rank 1
answered on 13 Oct 2013, 11:19 AM
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!
0
Христо
Top achievements
Rank 1
answered on 15 Oct 2013, 06:28 PM
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 :)
0
Steve
Telerik team
answered on 18 Oct 2013, 11:06 AM
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.
0
Leonard
Top achievements
Rank 1
answered on 20 Mar 2014, 06:15 PM
How can I get user profile data and display user profile picture on my app? Thanks.
0
Leonard
Top achievements
Rank 1
answered on 21 Mar 2014, 09:52 AM
Where should I put 'window.location...' in the script?
Thanks.
0
Stefan Dobrev
Telerik team
answered on 25 Mar 2014, 07:45 AM
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.

 
0
Leonard
Top achievements
Rank 1
answered on 26 Mar 2014, 02:04 AM
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?
0
Zdravko
Telerik team
answered on 28 Mar 2014, 01:12 PM
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.

 
0
Leonard
Top achievements
Rank 1
answered on 03 Apr 2014, 10:32 AM
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 :)
0
Leonard
Top achievements
Rank 1
answered on 04 Apr 2014, 12:30 AM
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.
0
Zdravko
Telerik team
answered on 08 Apr 2014, 09:07 AM
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!

 
0
Austin
Top achievements
Rank 1
answered on 05 Jun 2015, 12:49 AM

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.

0
Zdravko
Telerik team
answered on 09 Jun 2015, 02:28 PM
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.

 
Tags
General Discussion
Asked by
Robert Sprague
Top achievements
Rank 1
Answers by
Jan-Dirk
Top achievements
Rank 1
Jordan
Telerik team
Hongyi
Top achievements
Rank 1
Владимир
Top achievements
Rank 1
Steve
Telerik team
Saravana
Top achievements
Rank 1
Noel
Top achievements
Rank 1
Chris Gillies
Top achievements
Rank 1
Христо
Top achievements
Rank 1
Leonard
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Zdravko
Telerik team
Austin
Top achievements
Rank 1
Share this question
or