We are in the middle of creating a PhoneGap-based application using AngularJS and the Ionic framework.
This application is a store management system that communicates with an existing web application using OAuth2, and we have a problem with Android redirection after authentication.
The event listener is configured as follows to close the InAppBrowser window either upon successful connection or cancellation:
if (runningInCordova) { connectWindow.addEventListener('loadstart', function(event) { var url = event.url; if (url.indexOf("code=") > 0 || url.indexOf("error=") > 0) { return callback(url).then(function() { connectWindow.close(); }, function() { connectWindow.close(); }); } });
For browser testing purposes, a local host redirect URL is also defined:
http:
On iOS, this works fine, and InAppBrowser closes immediately when needed, but on Android there is a delay before this event listener fires. As a result, the following error message is displayed for about 1 second:
Web page not available The web page at http://localhost:8100/oauthcallback.html could not be loaded as: net::ERR_CONNECTION_REFUSED
Then the event listener starts and the window closes.
Is there a way to speed up the start of the event listener to avoid this error?
Many thanks
source share