ng-cordova-oauth
ng-cordova-oauth copied to clipboard
Suggest inappbrowser open as hidden
Perhaps open the inappbrowser as hidden and look for the loadstop event to show. Many times the web page will not load because the site is down or not available, worse the network connection is down. This causes the app to hang to the user because the inappbrowser is blank. $timeout is needed to kill the browser if this happens.
Thanks for the suggestion. I'll take it into consideration :-)
That is a very common issue. When network is "floating" between online and offline states, you can end up having a NET::ERR_CONNECTION_TIMED_OUT or other similar error tossed out of inAppBrowser
How would loadstop catch such an error and get the user back to the app?
Its more of a dirty trick to keep the flow through the browser from getting stuck. If the connection does not come to life you end up closing the inappbrowser with a timer, if the connection is good then you show it. Once it is shown you could still have other network issues but at least you know you got to Facebook to begin with.
var browserRef = cordova.InAppBrowser.open(flowUrl,
'_blank', 'hidden=yes,location=no,clearsessioncache=yes,clearcache=yes');
var timerPromise = $timeout( function(){
if(wifiFlag == false){
browserRef.removeEventListener("exit",function(event){});
browserRef.removeEventListener("loadstop",function(event){});
browserRef.close();
window.plugins.toast.showLongTop($translate.instant('_CONNECT_TMEOUT'));
}
}, 10000);
browserRef.addEventListener('loadstop', function(event) {
$timeout.cancel(timerPromise);
// If the event.url is the same as the url we called then the site was not found
// because there is no redirect. Cause no wifi or data connection.
if(flowUrl == event.url){
//console.log("loadstop");
browserRef.removeEventListener("exit",function(event){});
browserRef.removeEventListener("loadstop",function(event){});
browserRef.close();
window.plugins.toast.showLongTop($translate.instant('_CONNECT_INTERNET'));
}
wifiFlag = true;
browserRef.show();
});
Did not see your answer, but I have done it thru a different approach (without timeout). I will make a commit on my repo.
Pull requests are always encouraged if you want to contribute to this project.
What happened to this? can it be used somehow? any docs?
I don't believe @ffabreti ever made me a PR.