I want to use the "Write once, run everywhere"
So I created a PWA in reactjs with create-react-app.
My app works greatly, and I can put it on the home screen of my mobile from the website. However, I want to be visible on mobile stores too (starting with Google Play).
I tried:
Is there a way today to deploy a reactjs PWA app on a store? That would realize my great dream about progressive web apps :)
months ago I've developed a small ReactJS application using Cordova/Phonegap that actually works so I think you miss a couple of details in order to make your application works.
First, did you wait the deviceready event before to bootstrap ReactJS? Your entry point should be something like this ( code is quite old, I used it in an old AngularJS application and adapted it just to bootstrap ReactJS )
var appName = 'myApp';
var PhoneGapInit = function (appName) {
this.boot = function (appName) {
ReactDOM.render(
<Router>
<Route exact path="*" component={ApplicationAsync} />
</Router>,
document.getElementById('root')
);
};
if (window.cordova !== undefined) {
// "Found Cordova";
var self = this;
document.addEventListener('deviceready', function() {
self.boot(appName);
}, false);
return;
}
// 'PhoneGap not found, booting manually';
this.boot(appName);
};
window.addEventListener('load', () => {
new PhoneGapInit(appName);
});
Second, using Webpack I've found necessary to use this webpack plugin to have cordova object available, https://github.com/markmarijnissen/webpack-cordova-plugin ( everything is explained there )
Moreover your index.html should contain a body tag like this
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<script type="text/javascript" src="cordova.js"></script>
</body>
The first step should be enough to have your application running.
Also, it is important to know that using Chrome it is possible to access the console to see what is happening in the application, just follow these steps
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With