Currently I am developing a login registration app which also involves a chat application and other real time updates. And for the backend server, I am using NodeJS as the backend language and use a MySQL db. The thing is I have no idea how to do them in the most prudent way. Here is how I am doing it now:
1) Use Socket IO as the main means of communication for the chat message. However, I just send a push notification to the user using GCM. So two questions here: should I save the chat messages instead of loading it from the server every time? If so, what is the best way to save all the messages in android? I use GCM as nothing but a mean to notify the user for I do not know if I can trust it EVERY TIME since it uses another server.
2) Storing the GCM id’s in the database…how do I do that properly? So let’s a user is using my app with the same account on 2 or more devices. Currently, the temporary solution I came up with works like this: a. I have a separate table in DB called gcm which has 3 columns: id, user_id, gcm_reg_id and every time a user registers, it checks for the GCM Id of the device and if the registered gcm_reg_id doesn’t match the user’s current gcm_reg_id, it will create a new row with gcm_reg_id. Now that user have two gcm id’s register under their user id. So If the user receives a push notification from someone else, the gcm will send notification to both devices. Now that is a problem if the some other user is logged in one of the devices…so to counter that, I verify if the push notification should be shown or not by using the user_id…I understand this has major security flaws, but what is the best way to store the GCM ids and verify if it is being set to the right user?
3) Socket IO android client can be a bit buggy sometimes. Should I use good old XMPP? Or what is more reliable?
Thanks for reading. Please do help me.
Aucun commentaire:
Enregistrer un commentaire