简体   繁体   中英

How can I use my Expo App on a real device?

hope you are all safe.

I have created an Expo App that has a Frontend and a Backend that uses a REST API to communicate with a PostgreSQL DB. Currently everything is running locally.

My Backend is communicating with the DB. I have all SQL operations in there and the whole Server File is an own Folder that I start with npm run server in my VSCode - thats when my Server starts to listen.

My Frontend then uses the defined routes with the PC IP-Address to communicate with the Backend.

Like: fetch( http://192.xx.50.xx:6969/api/hours/deletehour/${hourId} )...

What I am thinking is that the part before /api/... needs to change and it has to be the real device IP.

  1. How do I get the real device IP and use it to communicate with my Backend?

  2. Does my Backend and my Frontend has to live in the same Folder for it to work? They are currently seperated in 2 Folders. Also should there be a generall script that runs when the app starts? So the server gets started up or something?

  3. Does my PostgresDB needs to be put on a remote server or can it be accessed as long as the user uses the same Wifi or Domain?

Help would be really appreciated because I cant imagine how to run it on a real device and not locally on an Emulator as it is currently.

  1. What steps are there to do before an App can be shipped? Some security or connection things?

I know for example that updating the App should work easily because it is build with Expo and Expo supports OTA Updates ("over the air").

Thanks Faded.

You haven't mentioned the serverside programming language you are using. Incase you are using PHP then you can host it on godaddy or any other providers but you will have to buy a domain too.

If it's Node.js or something else then you have to deploy it in cloud or dedicated server or vps but it's relatively easy to test your services with AWS(amazon) or Azure(microsoft) or Google cloud.

For a quick start you can create a free ec2 server in AWS. Every ec2 server will get a public ip address and you can have PostgreSQL DB on the same server (connect with localhost/127.0.0.1)

When you are done with testing you can host them in different ec2 servers and choose the servers according to your needs. Explore other services offered by AWS or any other provider you would like to go with.

Your backend and frontend doesn't really have to be in the same folder. In case you are deploying to expo or as a standalone app to app stores then your app bundle will be in respective app store servers (Apple or Google) and your backend will be maintained by you in publicly accessible servers as explained above.

Just Google about it. You will find enough information and also read about deployment of expo apps and deployment of your REST API separately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM