GetStream / stream-chat-swift

💬 iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API
https://getstream.io/chat/sdk/ios/
Other
856 stars 209 forks source link

UserInfo imageURL is return nil #1399

Closed Cu-Toof closed 3 years ago

Cu-Toof commented 3 years ago

What did you do?

I sent userInfo when connecting to user

guard let token = try? Token(rawValue: token) else { return }
let userInfo = UserInfo(
    id: UserId(profile.id),
    name: profile.username,
    imageURL: URL(string: profile.avatar)
)
ChatClient.shared?.connectUser(userInfo: userInfo, token: token, completion: completion)

What did you expect to happen?

When I send a message, UserInfo should be returned as Author in ChatMessage.

What happened instead?

Currently, Author's imageURL return nil

GetStream Environment

GetStream Chat version:4.0.0-beta.11 GetStream Chat frameworks: StreamChat, StreamChatClient, StreamChatCore iOS version:14.7.1 Swift version:5.0.0 Xcode version:12.5.1 *Device:iPhone XR*

Additional context

tbarbugli commented 3 years ago

Thank you for reporting this, I just tested this on our sample app and I can't reproduce the same problem. Can you change loglevel and paste the response from the API here?

LogConfig.level = .debug

You can see the reply from API when connection is done if search for [webSocketDidReceiveMessage(_:)] > Event received: in your logs and then message.new to see the event send around when you send the message (both should have "image_url" in there)

Cu-Toof commented 3 years ago
2021-08-25 13:14:38.887 [DEBUG] [io.getStream.chat.core.web_socket_engine_queue] [WebSocketClient.swift:188] [webSocketDidReceiveMessage(_:)] > Event received:
{
  "user" : {
    "banned" : false,
    "online" : true,
    "id" : "hiidol1",
    "role" : "user",
    "created_at" : "2021-08-25T05:54:06.103684Z",
    "image_url" : "https:\/\/wanfang-file.s3.amazonaws.com\/2021-08-15\/61187fd9631ad.png",
    "updated_at" : "2021-08-25T06:01:59.661382Z",
    "last_active" : "2021-08-25T06:14:09.272663363Z",
    "name" : "hiidol1"
  },
  "watcher_count" : 1,
  "channel_type" : "livestream",
  "channel_id" : "schedule-78",
  "created_at" : "2021-08-25T06:14:38.996535857Z",
  "message" : {
    "updated_at" : "2021-08-25T06:14:38.987204Z",
    "reply_count" : 0,
    "html" : "<p>hdhdhshhs <\/p>\n",
    "type" : "regular",
    "own_reactions" : [

    ],
    "cid" : "livestream:schedule-78",
    "id" : "1189891B-0F50-468E-B12A-5FCF16499B47",
    "user" : {
      "banned" : false,
      "online" : true,
      "id" : "hiidol1",
      "role" : "user",
      "created_at" : "2021-08-25T05:54:06.103684Z",
      "image_url" : "https:\/\/wanfang-file.s3.amazonaws.com\/2021-08-15\/61187fd9631ad.png",
      "updated_at" : "2021-08-25T06:01:59.661382Z",
      "last_active" : "2021-08-25T06:14:09.272663363Z",
      "name" : "hiidol1"
    },
    "shadowed" : false,
    "pinned_at" : null,
    "pin_expires" : null,
    "attachments" : [

    ],
    "reaction_counts" : null,
    "reaction_scores" : {

    },
    "silent" : false,
    "text" : "sdkjskdfhkdjfhskj",
    "pinned_by" : null,
    "created_at" : "2021-08-25T06:14:38.987204Z",
    "mentioned_users" : [

    ],
    "pinned" : false,
    "gift" : "Toan",
    "latest_reactions" : [

    ]
  },
  "type" : "message.new",
  "cid" : "livestream:schedule-78"
}

@tbarbugli I see imageUrl is not nil, but I get imageUrl that is nil from author on the list message. channelController?.messages.map { $0.author.imageURL }

nuno-vieira commented 3 years ago

@Cu-Toof This is still not reproducible on our side. Can you verify if the imageURL is nil or if actually what is happening maybe is that channelController is nil and the reference was somehow lost? Or maybe the $0.author is nil?

Thank you!

tbarbugli commented 3 years ago

@Cu-Toof please reopen if you are still experiencing this problem