Logging into Facebook with PhoneGap / Cordova

I recently turned on the phonegap-facebook plugin ( https://github.com/phonegap/phonegap-facebook-plugin ) on iOS and Android (same app).

I want to do something that, in my opinion, will be simple: get around the call on your native facebook for login / authentication and always use the web dialog . How can this be done?

My login code currently looks like this:

Initialization Code:

//facebook initialization FB.init({ appId: 'xxxxxxxxxxxx', //'<%#= FB_APP_ID %>',//'', nativeInterface: CDV.FB, useCachedDialogs: false }); 

And a call to enter:

 FB.login(function(response) { if (response.authResponse) { // connected me.signInFacebook({ token: response.authResponse.accessToken, email: response.authResponse.email, success: function (data) { // hide login view and show tabview form.destroy(); // continue whatever action was previously happening me.continueAction(tabIndexBack, callback); }, failure: function (response) { // show errors Ext.Viewport.down('tabscontainerview').setActiveItem(3); } }); } else { //go back Ext.Viewport.down('tabscontainerview').setActiveItem(3); alert('fb login error'); } },{ scope: "email" }); 

Thanks for the help!

+7
source share
4 answers

I created a plugin to facilitate the connection between Facebook and telephone communication without using the Native plugin only with jQuery:

https://github.com/studiosoton/faceGap

+4
source

To get around your own login to FB, you can make your own facebook authentication stream without using the Facebook JavaScript SDK ( https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.3 ) via plugins inAppBrowser or ChildBrowser.

Your application should initiate a redirect to the endpoint, which displays the login dialog:

  https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}&response_type=token&scope=email 

Facebook redirects people to the redirect_uri mentioned above and places an access token along with some other metadata (such as token expiration time) in the URI fragment:

 https://www.facebook.com/connect/login_success.html# access_token=ACCESS_TOKEN... 

Your application should detect this redirect, and then read the access token from the URI. Then you can proceed to the verification tokens verification step.

+1
source

In the Android plugin version, you can force it to use the dialog by changing the way the plugin calls me.facebook.authorize in the login action of the org.apache.cordova.facebook.ConnectPlugin class.

You need to pass an additional activityCode parameter using Facebook.FORCE_DIALOG_AUTH :

 me.facebook.authorize(cordova.getActivity(), me.permissions, Facebook.FORCE_DIALOG_AUTH, new AuthorizeListener(me)); 

I'm not quite sure about iOS, but you can try openWithBehavior and FBSessionLoginBehaviorForcingWebView

0
source

Without any Facebook plugins, you can use the functions of Facebook, for this use phonegap.facebook.inappbrowser.js using this js. You can easily access all the features of Facebook for more information, visit this URL: Integration with Facebook without any plugins

0
source

All Articles