display facebook login through native app or web browser on ios using javascript

1.3k Views Asked by At

im creating an ios app using appgyver and steroids using HTML/javascript

Im able to display and login the user to facebook using this method

window.location.href = 'https://www.facebook.com/dialog/oauth?client_id=XXX&redirect_uri=http://localhost/views/appdir/facebook.html&scope=email,read_friendlists'

what this does is open the facebook login page in my app.

what i would like is instead of this when the user clicks the login button it opens the login screen on the native facebook app then redirects back to my app after user has logged in.

or if the native facebook app does not exist then it opens the facebook login page in the web browser(eg safari) then redirects back to my app after the user logs in.

the reason y i want this is becuase when it opens the facebook login page in my app there is no option for the user to cancel the login and return back to the previous page. also if the user clicks on the link 'click here to download the facebook app to your phone' then the user gets redirected to the appstore and leaves my app with just a blank white page in which it cannot recover and my app has to be restarted.

if its possible to do either of the two that i asked it would be great or if there is some other soloution would be great also.

1

There are 1 best solutions below

0
On

Try Cordova Facebook Plugin. It uses the native Facebook app for login and, if it's not available, it will use the standard dialog based authentication. Here are the instructions how to set it up with AppGyver Steroids.