1

I am using webViewInterface plugin in nativescript 8 with webpack v5 I am trying to launch local downloaded file ex. video, audio, HTML files

I am able to download those files but while running that file with the help of webview I am getting

file not found

error

chromium: [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property '_onNativeEvent' of undefined", source: chrome-error://chromewebdata/

In NativeScript, by default, the tilde (~) marks the app root folder (note the App and not the Project!). So if my file is located in <project-name>/app/index.html then I need to set a path like this ~/index.html.

this was working fine with natviescript v6 but after upgrading to nativescript v8 it broke.

can anyone please help???

Ragesh Pikalmunde
  • 1,333
  • 1
  • 20
  • 44

2 Answers2

1

OK i have what seems to be the same issue. In my case when i migrated from nativescript 7 to 8 the webpack.config.ts was cleaned up. In there was something useful that copied all my webview files.

I added some code to my webpack.config.js and now it seems to work "src" is the folder containing my webview folder.

const webpack = require("@nativescript/webpack");

module.exports = (env) => {
webpack.init(env);


webpack.Utils.addCopyRule({
    from: 'webviews/**',
    context : 'src'
})

return webpack.resolveConfig();

};

The doc I used.

NS 8 : https://docs.nativescript.org/webpack.html#adding-a-copy-rule

Previous plugin used : https://webpack.js.org/plugins/copy-webpack-plugin/

Vilcoyote
  • 115
  • 1
  • 7
0

The app folder is read-only on iOS (at least, on real devices, not necessarily on emulators). You'll need to download the files to either the temp or documents folder and then access from there.

As a reference, see my own struggle with this issue.

David
  • 578
  • 3
  • 16
  • 1
    is it same for the android as well, as I am facing this issue on android device – Ragesh Pikalmunde Feb 01 '22 at 17:26
  • I just migrated from nativescript 7 to 8 and facing the same issue. Everything was working fine but now i also get the file not found. I just took over the development of theapp so i don't know what to add that could help. I've noticed that if explore on my smartphone the folder "files" (containing /files/app/www/index.html) doesn't exists. I don't know if it's because it really doesn't exists and the files should be loaded there or because it's not visible for security reason. I'm just not experienced enought with nativescript and mobile development in general. – Vilcoyote Feb 02 '22 at 13:09