Titanium mobile app - Communicating Between WebViews and Titanium UI

Few days back, we were facing problem establishing communication between a Webview control and a Titanium UI or vice versa. We were integrating Facebook authentication in our Titanium mobile app using Titanium Facebook mobule where we stumbled upon this issue. We wanted to trigger FB Auth Titanium module specific code on click of an HTML Login button tied with a jQuery click event. The FB auth module checks if Facebook mobile app is installed on the device and opens this mobile app for authentication otherwise it opens the browser window popup and redirects to Facebook site to authenticate. This is