I have an existing React application and I'm trying to port it to iOS and Android.
I managed to run the application on iOS simply changing from regular routes to hash routes.
import { createBrowserHistory, createHashHistory } from 'history';
import { IS_HYBRID_APP, IS_PROD } from 'utils/environment';
export const history = window.cordova ? createHashHistory() : createBrowserHistory();
const connectRouterHistory = connectRouter(history);
This approach did not work on Android though. The navigation is broken.
Any advice?
CONTEXT:
The steps that I did are:
ENVIRONMENT SETUP:
npm install -g cordova
- Installed Java 8 (versions greater than 8 are not supported)
- Installed Android Studio
- Added JAVA_HOME, ANDROID_HOME and GRADLE_HOME to my PATH — Added the emulator to the path
- Installed the right sdk executing: sdkmanager “platform-tools” “platforms;android-27”
- Added an emulator in Android Studio
APP PREP AND LAUNCH:
npm install
cordova platform add android
rm -rf www
react-app-rewired build
// vvv - injects the cordova script and the CSP meta tags into build/index.html
node config/hybrid-app-build.js
mv build www
cordova start android
Same result both on emulator and on a real device. The routing does not work properly while everything else seems correctly in place.