Android: Users comment implementation - android

Hi my app lets users post/share photos, and comment. App and server communicate via JSON. I'm looking for an effective way to let users know if there are new comments and mark as read after they read them.
I have a comment table on the server, do I add a column with tinyint as 'read' boolean? And how do I automatically set a comment record to true when they are accessed/selected?
Thanks.

Since your app nature shows that you need to save read/unread status on server side (also other desired information). So whenever your server get to know that some User A has posted a comment for some User B you will send a push notification to B telling the app that a new Comment has been posted. When user click the comment to read it just send a notification to server telling him that this comment has been read and server will mark it read in its database. Thatz it

Related

group chat in flutter using firebase with a twist

Disclaimer: I have never worked with firebase or any other DB so my idea is pretty rough and I will be glad if u correct me in some of my assumptions. Also this is my first question on StackOverflow so I hope it will be detailed enough.
I am currently working on my project which is basically a group chat in flutter using firebase, where I should be able to create a new group chat(create a new DB in firestore) trough the app, let other ppl join(assign them to the new group chat DB).
The twist: If I send a message to the group chat I want other ppl to see a pop-up saying: "do you accept this message", no=> doesn't show / yes=> Shows the message but deletes it for others.
This app is nothing but my idea of how to confirm my theory and also learn a little bit more about both flutter and firebase, so please do not mind if it's useful or not.
Assumption: Each groupchat has it's own DB (Can I create a DB in firestore trough app / send request to?)
Question: Can I assign a specific ID to each message and choose and further edit who is going to be able to see the message trough the app(app_instance_1"I accepted the message so only I and sender can see it")?
Here's a great article for making a Flutter chat app: https://medium.com/flutter-community/building-chat-app-in-flutter-with-firebase-888b6222fe20. If you need more detail or help just write a comment.
About your assumption. Each app usually is connected to one database, and within the database, you can have separate documents to hold each group chat. You can also set up documents for each individual user to save the chats that only they can see. Within documents, you add collections that hold your data.

how to connect other user with opentok?

Bless To all
I am developing an application in which i am implementing instant Messaging,Voip audio call and video call through using opentok/tokbox.I read all documentation it was though easy but not very much.But i am confusing at a point.Lets suppose if i have three user in my android application say A,B,C.
if user A wants to message with user B then how user B will know that he have to receive message from that session that is assigned to user A?how user A will send message that will go directly to user B.
Hope you all understand the question.Would like to hear any suggestion from you.and if anyone worked other plateform for these 3 features(instant messaging,voip audio,video) for free or trial.Please let me know also.
Thanks in advance
Your server will need to coordinate users and sessions using logic that you implement yourself. This will vary greatly depending on the server side language you use and the type of application you're creating.
Based on your example, your server side implementation needs to pair user A and user B together and give both users the same session ID so when they initialise and connect to that session, they can see each other.
If you've already read all the guides found at https://tokbox.com/developer/guides/ then make sure you also take a look at the sample applications https://tokbox.com/developer/samples/ They don't match your use case exactly but demonstrate how to create a 'room' that both users can visit to retrieve the same session ID.
The way opentok Sessions are structured is more like a conference call than a direct phone call which is what makes it confusing. But it's still possible to get the behaviour of a phone call. There are a couple of different ways you can do this.
You can create a session for every user. Then if user A wants to message user B, they connect to User B's session and send a signal. This requires you to keep track of which sessionId applies to each user.
Everyone is connected to the same giant session. When user A wants to message user B they send a signal to user B's connectionId. You can use the connection data property to put eg. usernames in the connections to help you keep track.
You can use a 3rd party service for messaging and just use OpenTok for the audio/video part.
Hope that helps.

Sending simple data with notification to another app

I'm working on two seperate apps that need at some point to exchange messages, both apps share a MYSQL database, I want the first app to be able to send some data to one of the other app's users (specified by his id, email or phone number ), and this last to be able to reply to the request by accepting or rejecting with a button click.
Now, I don't know what is the best:
Something similar to chat ?Is it possible to extract the necessary data from the rest of the chat message ?
A broadcast.
A push notification.
Or something else ?
Help me please I'm a total newbie, I would use an expert opinion.
What you are describing is basically every other Chat App that exists.
I can only suggest you to read this code example to get an idea how to approach this:
Android Chat Example code

How to integrate friend list feature in an Android App?

I would like to have a friend list feature in my App. The idea is to select any contact from your contact list and then that contact would be sent an SMS from the App(via Server), requesting him to click on the link to accept the friend request, if he is already on the App. If he is not on the App, the SMS would send him a download link. How can I achieve this? Any help would be highly appreciated.
EDIT:
So far, when I select the contact, it gets added in my friend list, with an "!" mark that the request has not been approved at the other end. The other guy gets an SMS as well from the App(via Server) to accept the request by clicking on the link. Now when the other guy, clicks on the link(just a demo link as of now), how do I make him accept the request? Any suggestions would be highly appreciated.
You have nearly completed the job at hand.
Here is what you can do to finish it.You will need to maintain a mapping of which number sent which other number a link on the server. I have not understood how a single link for all requests is going to suffice what you need to do(else you will need a way to generate unique links and handle what happens when each is clicked on!). I dont think that is possible. The user onclick on the link could be redirected to new activity which will pull friend-requests from the server from the mapping availabe. The user could accept or reject the requests here. You see a single link will fail to provide functionality of multiple requests the user gets. Once the second user has one this, you can notify the first user of the same(maybe via GCM or by polling from the device(not efficient!)). I hope my interpretation of the task at hand was right.

Synchronize Android client and REST server

REST Server
I created a Rails server that contains :users and associated :comments. It is used as a backend API for an Android client. The exchange format to load and store data at the server is JSON. Here are the relevant migrations.
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.timestamps
end
end
end
...
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.references :users
t.string :subject
t.text :message
t.timestamps
end
end
end
All users have already been imported. Therefore, only read access is configured for the :users resource. Thus, for :comments it should be possible to add new entries. Here are the available routes.
user_comments GET /users/:user_id/comments(.:format) comments#index
POST /users/:user_id/comments(.:format) comments#create
new_user_comment GET /users/:user_id/comments/new(.:format) comments#new
user_comment GET /users/:user_id/comments/:id(.:format) comments#show
users GET /users(.:format) users#index
user GET /users/:id(.:format) users#show
Android client
On the client side I use a Service with AsyncTasks to download, parse and store users into a local SQLite database. A ContentProvider delivers cached users to the UI. The user object downloaded from the server contains the unique id of the users table. This should be useful when a new comment gets created on the client.
Scenario 1: Read comments
Users are displayed in a list view on the Android client.
A user item gets selected.
The list activity creates an Intent which contains the user specific URI, e.g. content://com.example.myapp.provider/users/23.
A user activity displays detail information about the user and associated comments.
Cached comments get loaded via a CursorLoader. (1)
A synchronization process loads comments from the remote server. (2)
Scenario 2: Write comments
A comment can be created from the user activity.
The comment gets stored into the local database. (3)
Stored comments are sychronized with the remote server. (2)
Headache questions
I marked the scenario steps that are associated with the following questions.
How do I create a content URI for the comments being used with a CursorLoader in the user activity? Please mind, I only know the user URI at this point.
Can someone describe how I create a synchronization process? I am not sure if a SyncAdapter works here (never used it). Is the the synchronization process just a Service that on the one hand starts tasks to download, parse and store comments on the client and on the other hand loads, encodes and sends out comments to the server?
How does the content URI for a new comment look like? Is the ContentProvider for comments the same as for users? Is there only one SQLiteOpenHelper in the application?
The main problem I am struggling with is how to design the application? If you know of a better solution on how I should synchronize the users and their associated comments, you are very welcome.
Answers
Answers to question 1. and 3.
I extended the REST model as follows: The JSON hash returned for a comment now includes the id of the associated user. The same id is also included in the JSON hash for the user. Both objects are stored into the local database on the Android device. This allows me request comments for a specific user. I simply pass the server user id as WHERE clause. The content URI for comments is not cascaded as I implied with my question. It is similar to the user content URI:
content://com.example.myapp.provider.commentsprovider/comments
Note, that I changed the authority part of the string. I decided to create separate content provider for users and comments.
One simple architecture is to always update things in the server first, sending posted comments to the server right away and from there pushing a notification through GCM to users that should request the updated comments list. The flow would look like:
When the app is open send GCM registration id to your push notification server (say uniqush-push, or your own server using a gem to handle the GCM logic), this way you can use it to send push notifications to the user telling the app to update the comments from the server
Build your initial cache as you want it
Whenever a user posts a comment, send it to the server and make the server respond with the data for the created comment, so the app can use that and already cache it if it wants, using the returned id and whatever else
On the server, when a comment is posted, loop through all the concerned users and using the GCM registration id send it a push notification, it could be as simple as having just "update_comments": "1"
On the app when the push notification is tapped by the user, update the comments cache with a request to the server

Categories

Resources