Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

WebView: detect close event (Facebook login stucks app on blank page)

$
0
0

Hi,

I'm trying to build a very basic app (Android) and I need to include a (remote) mobile website with Facebook login. I do it with a WebView, and my website uses the FB JS SDK.

The user is indeed prompted for his credentials when hitting the FB button. Yet, this creates a new window (a popup on desktop), that closes itself once the user has authorized the app. But "closing" the popup in a webview actually means that the screen goes blank and nothing happens (except a weird warning in loop: Unsafe JavaScript attempt to access frame with URL http://my.website.me/ from frame with URL https://m.facebook.com/dialog/oauth?access_token=PTEE...&app_id=XXX&client_id=XXX&display=touch&domain=my.website.me&e2e=%7B%7D&origin=2&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2Fxx.js%3Fversion%3D41%23cb%3Dfxxx%26domain%3Dmy.website.me%26origin%3Dhttp%253A%252F%252Fsmy.website.me%2Fxxx%26relation%3Dopener%26frame%3Dxxx&response_type=token%2Csigned_request&scope=public_profile%2Cemail&sdk=joey. Domains, protocols and ports must match.).

From there, I can hit the back button to return to my website but this is obviously an UX no-go.

So, I need either:

  • to detect the window.close event to redirect the user once he's logged in,
  • to find a better way to do this.

For the first option I can inject some JS in the FB login page with evalJS but I'm not sure how to transmit back the "I'm gonna close myself" event to Titanium. Docs say it's not possible but Titanium sees stuff happening on the webpage since my debug log shows the console.log output. So there is some kind of communication, how could I use it?

For the second option I'm open to any suggestion, of course!

The real goal here just being to log in with Facebook. (I don't want to use Titanium's Facebook API to pass some auth token to the website because if my user needs to share something later, the problem will be the same with the ShareDialog)

Thank you!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>