Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a mobile app from my web site using reactjs (not native)

I need to develop a mobile application which will be same for my web site (already create with reactjs). I was researching on reactjs. Can I convert my reactjs code from web-site to reactjs for mobile application ?

need a solution please Thanks

like image 609
mitsu Avatar asked Jan 01 '23 16:01

mitsu


1 Answers

No bro, a PWA cannot be uploaded to the apple store, by the way you can bypass this problem using ionic capacitator!

Capacitor is a cross-platform app runtime that makes it easy to build web apps that run natively on iOS, Android, Electron, and the web. We call these apps “Native Progressive Web Apps” and they represent the next evolution beyond Hybrid apps.

According with this tutorial written by Manish Mandal to do so u have to:

1 - First, go to the root of your existing react app and create a file capacitor.config.json and inside that put the below code

{
  "appId": "io.ionic.yourapp",
  "appName": "yourapp",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "build",
  "cordova": {}
}

2 - Now create another file name ionic.config.json and inside that insert the below code.

{
  "name": "yourapp",
  "integrations": {
    "capacitor": {}
  },
  "type": "react"
}

3 - Now we need to build our react project. To build your react app open your terminal to the root of the project and run the below-mentioned command

npm run build

Note: this will create the build folder in your root porject and the name of the folder should match the webDir name inside capacitor.config.json file

4 - Now we will install ionic globally in our machine. To install ionic globally in your machine open your terminal and run the below command.

npm install -g @ionic/cli

5 - Now install the capacitor core in our project.

npm install @capacitor/core --save

ANDROID

6 - After that, we will first create an android app with our existing react app. Open your terminal and type

ionic capacitor add android

This will create the android folder in your root project and install all the required dependencies.

7 - Now run the below command to open your android project in android studio.

npx cap open android

Wait some time and then it will ask you to update the Gradle. Just update the Gradle to the latest version and run the project in the emulator. You can also connect your mobile to run the project live on your mobile phone.

8 - Now open the build menu from the android studio and build your apk file.

IOS

9 - To create ios app run the below command

ionic capacitor add ios

This will install all the required dependencies and ios folder to your project.

10 - Now run the below command to open your ios project in Xcode.

npx cap open ios

11 - Now open the app in emulator or physical device and build the app.


More info about capacitator: https://capacitorjs.com/

like image 157
Filippo Secchi Avatar answered Jan 03 '23 06:01

Filippo Secchi