Im new in Meteor and React, building my first app for Android with it (I was on Angular1).
This app have many little games inside, I'm trying to serve those games from my resources/ folder.
My problem is: when I click in a title, an inappbrowser windows pop-up, and I want to serve my game there.
I've tried many ways to open a file inside resources/games/meme/index.html
but I always get: net::ERR_CONNECTION_REFUSED or net::ERR_FILE_NOT_FOUND (this last one when I used file:///games/meme/index.html
)
This is my code:
// here I have some settings
const inAppOptions = 'location=no,clearcache=yes,toolbar=no';
const target = '_blank';
// and here the code itself
if (Meteor.isCordova) {
Meteor.startup(function() {
let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions);
ref.addEventListener('exit', () => cordova.InAppBrowser.close());
});
}
So far, I've tried the let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions);
line with:
'file:///games/meme/index.html'
'/games/meme/index.html'
'/resources/games/meme/index.html'
'resources/games/meme/index.html'
And I've also placed the games/ folder and its contents inside the public/ directory, same result.
I have the cordova-whitelist plugin installed, and the App.accessRule('*', {type: 'navigation'});
inside the mobile-config.js
.
This is my folder structure:
MyApp
├── .meteor
├── client
├── imports
├── node_modules
├── public
│ ├── games
│ │ ├── meme
│ │ │ ├── index.html
│ ├── img
├── resources
│ ├── games
│ │ ├── meme
│ │ │ ├── index.html
│ ├── icons
│ ├── splash
├── server
│ mobile-config.js
│ package.json
I hope someone can help me, I didn't had this problem with ionic in angular, where the root folder is where I was, so I had to navigate like this: '../../resources/games/meme/index.html'
to get to the file.
Thanks in advance!
Edit: I tried to write the address manually in the chrome://inspect, and accessed successfully like this: localhost:12200/games/meme/index.html (this is on public/ folder), but I couldn't with the same address in the inappbrowser.
Just speculation here but I know that when developing for Android using React Native I can't use localhost
as it fails to resolve. Try swapping out localhost
for you're machine's IP address.