-3

I am creating an app using React-Native for the front-end, Java for the back-end and PostgreSQL for the database.

One feature of this app is to allow users to add each other as friends and instant message them - just like other social networks. At the moment, security is not a priority but I don't want to create something that I will have to completely redo when I do have to make it secure!

The goal here is to give each user the ability to send/receive messages to/from their friends. They also need to be able to view the message history with each contact.

I just need some advice on the following points to get me going as I haven't gotten very far on my own:

  • How should I send messages from the front-end, to the Java server and then to the receiver? This will involve the app having to listen for new messages so would the Socket.IO library be the way to go for this?
  • How I should store the messages in the database? E.g. have a table for messages with user_ids to be used for retrieval?

I should point out that I am very new to React-Native, databases and networking so I am finding this very challenging!

I will massively appreciate any help and any examples would be fantastic!

DJHignell
  • 9
  • 1
  • Do some research on API’s and you will answer your first question yourself. – Rob Walker Jan 23 '18 at 20:54
  • And do some research in database design and you will be able to answer the second question yourself. – Rob Walker Jan 23 '18 at 20:55
  • 1
    Being new to something is not an excuse. I've never done brain surgery, but I don't expect a doctor to give me a bloody private lesson just because "I'm new". What's worse, a lot of people asking these kinds of things have in their profile that they're university students. At that point you should realize that you're not a vessel for people to pour information and knowledge into, while you sit back and wonder. – Kayaman Jan 23 '18 at 20:57
  • I have done some research but the topic has not been easy to learn about on my own and I was hoping to get some help by reaching out to people who may have done this before. – DJHignell Jan 23 '18 at 20:59
  • 1
    You're expected to do a lot more research. You have an immense amount of information at your fingertips after all. Searching for information is an essential skill in the modern world. – Kayaman Jan 23 '18 at 21:02
  • I agree @Kayaman. However, I also believe that there is nothing wrong with asking others for advice. – DJHignell Jan 23 '18 at 23:04
  • Certainly not, that's the whole idea of this site. However, I've seen the "nothing wrong with asking for advice" claim before, and it's always the people asking for advice who say that, so...they would say that, wouldn't they. Anyway, here's the "official" policy of SO, and while it's written a bit tongue in cheek, it's worth reading: https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users – Kayaman Jan 24 '18 at 06:47

1 Answers1

1

You should use WebSocket on the server. Spring supports it

Here's a tutorial I wrote about sending messages from PostgreSQL to the browser using WebSocket, which isn't exactly what you're going to do, but can hopefully get you started:

http://blog.databasepatterns.com/2014/04/postgresql-nofify-websocket-spring-mvc.html

Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152