SurfEdge / flarum-mobile-android

An Android Webview wrapper for Flarum
110 stars 25 forks source link

Facebook Login #19

Open Felli opened 7 years ago

Felli commented 7 years ago

I believe something like this could help fix this issue. :+1:

chamathpali commented 7 years ago

That seems an old post i guess

Felli commented 7 years ago

Should still work how it is supposed to, I'll try to implement this later today if that is cool?

chamathpali commented 7 years ago

@Felli Yes sure. That would be great 👍

punitcodes commented 7 years ago

Since our App is not native, Facebook SDK won't help. Can you please try this

Felli commented 7 years ago

@punit2502 that is simple enough, I'll also do some test runs of this. :+1:

chamathpali commented 7 years ago

How is the progress on this @Felli any luck? 😃

Felli commented 7 years ago

Sadly no, I've not had the time as of yet to complete this, although I'll try to get this done by next weekend if possible.

duman commented 7 years ago

@chamathpali @Felli I found something. Due to Facebook using popup to login, webview gets a bit confused. Anyway, after you use Facebook to login there's a white page. Right? Now reload the page at that white page. 500 internal server erroe will come. Close the app and reopen it, you're logged in.

That may give some ideas. (Also white page URL is: "yourwebsite.tld/auth/facebook?code=fbauthCode")

For now, I just added:

public boolean     shouldOverrideUrlLoading(WebView view, String url) {
        String url3="https://m.facebook.com/";
        String url2="https://www.facebook.com/";
        // Above URLs should be improved because currently ANY Facebook link is considered as Facebook login attempt. Will fix it tomorrow.
        if (url.startsWith(url3) || url.startsWith(url2)).    {
            webView.loadUrl("A hidden static sorry Android Facebook login isn't currently available page link on your site") // can be avhieved by pages plugin
            return true;
            }  else  {
            return false;
            }
    }

And, here's how it looks in app. (When you press the Facebook login button.) how it looks

Felli commented 7 years ago

@dumanpro something similar to this here should be possible when dealing with the popup issue for Facebook login, there is also this here to take into consideration. 👍

duman commented 7 years ago

@felli disabling popups would just make it do nothing? Here's how Facebook works. You press the "login with fb" button. A new window opens. You enter your information. Allow using that app. The final link in that popup window is a flarum link. Which is example.com/auth/facebook?... at that window auth completes and popup closes. The window below now saved this via cookie manager and knows that you're logged in.

What we need is detecting a popup, and adding to onPageFinish, something like

url.startsWith("https://flarum.org/auth/facebook?") { webView.loadUrl("https://flarum.org"); }

I've tried this but there's a small problem. You can login Facebook. After window, you do get redirected to your flarum site, BUT, you're not signed in.

There's a way to sign in as I mentioned above but it's broken. Remember me adding swipe down to reload? Now step by step to login:

  1. Open app, and login via Facebook.
  2. At the white blank window (which is actually your site ./auth/facebook?...) swipe down to refresh.
  3. Get a 500 Internal Server Error.
  4. Close app via app manager. (Square button)
  5. Re open. You're now logged in with your Facebook account.

What I'm thinking is: There are some mobile games with Facebook login option. When you try to login with them they popup a new window, an actual popup with an X button on top left. If we can run Facebook on an external page like that, that'll be it.

I'll try to solve it now. If I can I will release a version with swipe down refresh + working Facebook login. (working anything popup login)

Felli commented 7 years ago

I myself am testing out this method here at the moment, and have a apk file created and waiting for testing, the only issue I'm having is creating a key hash for Facebook.

chamathpali commented 7 years ago

Facebook login is a crucial part we need to solve in the mobile apps. 😞 lets try to get some work around soon