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

Cannot access local files with inappbrowser on Android #178

Closed
pauldunn opened this issue Sep 26, 2018 · 5 comments
Closed

Cannot access local files with inappbrowser on Android #178

pauldunn opened this issue Sep 26, 2018 · 5 comments

Comments

@pauldunn
Copy link

I have a html file in my www folder called test.html.

I am trying to use the inappbrowser to open this file but I get this error on Android:
err::ERR_CONNECTION_REFUSED

IOS opens the file as expected.

Screenshot:
screen shot 2018-09-26 at 13 33 09

What I am trying to do is host a mini static website in the www folder so I can open this from my Ionic app with the inappbrowser.

Is it possible to do this?

@herbertbruno
Copy link

herbertbruno commented Dec 4, 2018

same problem.
Ionic:

ionic (Ionic CLI) : 4.5.0 (C:\Users\username\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, browser 5.0.4
Cordova Plugins : cordova-plugin-ionic 5.2.7, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.5, (and 21 other plugins)

System:

Android SDK Tools : 26.1.1 (C:\Users\username\AppData\Local\Android\sdk)
NodeJS : v6.11.0 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 7

@jcesarmobile
Copy link
Member

You'll need cordova-plugin-file to get the file system path, the localhost paths are only accesible in the Ionic WebView, but not in InAppBrowser

@herbertbruno
Copy link

That works. But we use localStorage to send back some data from InAppBrowser.
Since the URLs are different we face the cross domain localStorage problem,
From the app unable to access the localStorage that are set from InAppBrowser.

@jcesarmobile
Copy link
Member

Why do you open them in InAppBrowser instead of opening them inside the own webview? InAppBrowser was created to open external websites.

Anyway, next release of InAppBrowser will include postMessage, so you'll be able to communicate without localStorage "hacks" apache/cordova-plugin-inappbrowser#362.
And also current version provides executeScript that can be used to obtain the current localStorage

@herbertbruno
Copy link

we also use other UI frameworks instead of ionic, so to avoid conflicts we use IAB.
However I have tried the "postMessage" and it works.
Thanks,

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

3 participants