-3

I am developing an app in which there is a chatting functionality also , except chat my rest app is done now i want to integrate chat in my app for which i am trying xmpp , i have tried a sample for xmpp with my own jabbered server and its working. Following are my question are 1.How to integrate my app php data with jabbered server to show list of user chatting with there image , name , time and last message like the whats app chat list etc. like the image belowenter image description here

2.Flow of xmpp , like how its works example first the message is sent to FCM then to jabbered server and then to Device or it works differentely.

  1. How to manage chat history , do i need local database to maintain it or jabbered help for history also.

Any suggestion , link , example will be appreciated Thanks.

kim jot
  • 74
  • 2
  • 12
  • Is that all? Nothing more? – greenapps Nov 03 '16 at 18:04
  • 1
    Vote to close because it is more like to find a tutorial, book or something else which is explaining the coding of xmpp. You need to explain in detail with relevant part of code, where your problem is. Where do you stuck, what´s your goal, does your app throw an exception? – Opiatefuchs Nov 03 '16 at 18:07

2 Answers2

2

I think you are asking a lot of questions at once. The way you want to implement it all with your server depends on you. But the best I can say to my own knowledge is that chat storage on WhatsApp is done on the device. Messages can be stored in an Sqlite database. I use node.js to power my own server. It's not possible for me to give you the full detail of how it all links together but I can try by saying I have an xmpp client on my Node.js server. Once a user registers the xmpp client is made to register the user in the ejabbered server also with the same username. So since the user info is in the table with all of his/her details they can easily be queried for by username from the Android app.

You need to do some research on xmpp, and maybe Node.js and SQLite.

FCM is something different and you might not really need it in the flow

  • thanks mate , i have used php as back end so now i have to connect my php back end with jabbered server to make queries ? – kim jot Nov 04 '16 at 04:58
1

first sorry for my poor English. Answer for 1st,

XMPP Provides Register using PHP Service. Basically, Register from your device if successfully then register save user data in your server database. after register user you have to register user in XMPP, right now i don't have PHP snidest code.

other way is if user successfully register then it will give you register data. Take user id as register user in XMPP from your device.

i don't know how you manage your friend list but suppose you have user id using it concatenation suffix name with it you can send message.

Answer for 2nd,

You need refer document and make message format in XML and/or son . in Message format you have to define sender id, receiver id, sending time, message and you can define your custom attribute. sender send message in XML format and receiver evaluate message.

Answer for 3rd,

You have manage local database for individual chat because it server work is over after delivering message to you. In group it will provide history message but here also you have to manege local it's database.

hope this information help you.

Vasudev Vyas
  • 726
  • 1
  • 10
  • 28
  • hi thanks , suppose i have to login with username and password in my app login screen and that username and password is stored in my php server so i have to send that username and password also to jabbered server to get jabber id or any thing else to do ? – kim jot Nov 04 '16 at 05:47
  • Hi, at register time it will give me response user_id. now i use this user_id to register in xmpp username and password both, so this user_id should be my jabber_id too. while i successfully logged in , from its success response i run code for XMPP login in Async Task. I don't know this right way or not but it is working in me. – Vasudev Vyas Nov 04 '16 at 07:37
  • ok yes its seem to be right , can you tell how to connect php server with jabbered server so php user id can be sent to jabbered to assume it as jabber_id , who is the good person and better way to do this work php person or by android person ? – kim jot Nov 04 '16 at 07:53
  • It's better to be with PHP. I developed chat app ni Openfire same as EJabbered. i am not much aware about with Ejabbered but here i found one example refer this link : http://stackoverflow.com/questions/34305269/how-to-register-user-on-ejabbered-using-php-code – Vasudev Vyas Nov 04 '16 at 08:24
  • hi everything is working fine now , now i want to know how to get one to one chat history from ejabbered server.. is it possible or not or i have to do something else ? – kim jot Nov 07 '16 at 10:26
  • Hi i couldn't find any solution but in one to one chat i am store data in local sqlite. if you aware of Realm then you can also implement realm it is faster then sqlite. now you have to make Database in local to store message, sender_id, receiver_id,message Status, profile image and more as per your need of data. and to access those data make DAO . refer this : http://stackoverflow.com/questions/19154202/data-access-object-dao-in-java – Vasudev Vyas Nov 07 '16 at 13:20
  • i also think of that.. but how to manage chat history for different users like i logout one user and login with another user how i will get that user chat history from database ?? – kim jot Nov 08 '16 at 05:01
  • even whastapp not provide other user one to one history. Whatsapp like messanger follow to take backup – Vasudev Vyas Nov 08 '16 at 06:20
  • i have tried just now. Whatsapp is not provide other user one to one chat history after login with another account.now whatsapp is taking backup in given time duration which is define by user like daily,weekly,monthly to export online as well as offline. you have to make local database and take backup of this chat history.if user uninstall application and reinstall application and login with same account then it will find data offline or online and import database.so you have to export database to online or offline and when you need you can restore old chat history. this is only solution. – Vasudev Vyas Nov 08 '16 at 06:33
  • ok , but i think there is a way of getting chat history from e jabbered there is message achieving management which can give history , but i have to do some R n D on that. – kim jot Nov 08 '16 at 07:53