-2

chat image

my case is i need to specify my chat is from me or from response to make left and right chat . and my response chat also have 3 type of chat like text , image , and carousel. the problem is my response don't have sender / receiver to specify where is our chat , and where is chat response .

resolvequery is our send chat to api

i have make 2 custom cell for specifying my send chat and my response chat

this is my response

{
    "resolvequery": "text",
    "statuscode": 200,
    "timestamp": {
        "date": "2019-02-06 10:50:26.785700",
        "timezone_type": 3,
        "timezone": "UTC"
    },
    "result": {
        "output": [
            {
                "type": "text",
                "text": "Ini respons berbentuk teks",
                "speech": "Ini respons berbentuk teks"
            },
            {
                "type": "text",
                "text": "Ini adalah teks yang dipakai sebagai dummy response untuk message type text",
                "speech": "Ini adalah teks yang dipakai sebagai dummy response untuk message type text"
            }
        ]
    }
}
amaulana
  • 97
  • 1
  • 8
  • 5
    Possible duplicate of [How to give more than 2 custom cell on one tableView for chat](https://stackoverflow.com/questions/54642655/how-to-give-more-than-2-custom-cell-on-one-tableview-for-chat) – SPatel Feb 13 '19 at 04:52
  • noo its different . this question is for specifying chat type from me and from response – amaulana Feb 13 '19 at 05:16

1 Answers1

1

This will depend on your code architecture.

In all cases, the chat view on the right is the sender ( myself ), so logically, API should either give a boolean element that states if received or basically pass the sender user id with every chat text element, and check if the user id is equal to the current logged in id ( this means chat is sent and set to right), and if not then it should be on left.

Osa
  • 1,922
  • 7
  • 30
  • 51