Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest inappbrowser open as hidden #139

Open
wkande opened this issue Sep 28, 2015 · 7 comments
Open

Suggest inappbrowser open as hidden #139

wkande opened this issue Sep 28, 2015 · 7 comments

Comments

@wkande
Copy link

wkande commented Sep 28, 2015

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.

@nraboy
Copy link
Owner

nraboy commented Sep 28, 2015

Thanks for the suggestion. I'll take it into consideration :-)

@ffabreti
Copy link

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?

@wkande
Copy link
Author

wkande commented Mar 16, 2016

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();
            });

@ffabreti
Copy link

Did not see your answer, but I have done it thru a different approach (without timeout). I will make a commit on my repo.

ffabreti added a commit to ffabreti/ng-cordova-oauth that referenced this issue Mar 18, 2016
@nraboy
Copy link
Owner

nraboy commented Mar 18, 2016

Pull requests are always encouraged if you want to contribute to this project.

ffabreti added a commit to ffabreti/ng-cordova-oauth that referenced this issue Mar 23, 2016
…ginal function set on addEventListener

See https://issues.apache.org/jira/browse/CB-4819

extracted functions used for events so that removeEventListener would work as expected

Original issue: nraboy#139
ffabreti added a commit to ffabreti/ng-cordova-oauth that referenced this issue Mar 23, 2016
…ginal function set on addEventListener

See https://issues.apache.org/jira/browse/CB-4819

extracted functions used for events so that removeEventListener would work as expected

Original issue: nraboy#139
@mateosss
Copy link

What happened to this? can it be used somehow? any docs?

@nraboy
Copy link
Owner

nraboy commented Oct 19, 2016

I don't believe @ffabreti ever made me a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants