Unfollowed Status | Followed Status | Broadcaster Info Panel |
| | |
TUILiveKit/iOS/TUILiveKit/Source/Common/View
. For easier UI customization, an introduction to the files related to the follow feature is provided here.// File location:TUILiveKit/iOS/TUILiveKit/Source/Common/View/
View // Implementation directory of Live Room Information UI Component├── RoomInfoPanelView.swift // Detailed implementation of Live Room Information Panel View└── RoomInfoView.swift // Detailed implementation of Live Room Information View, clicking this view will display the detailed panel view
// File location:TUILiveKit/iOS/TUILiveKit/Source/Service/UserService.swift
func followUser(userId: String) -> AnyPublisher<Bool, InternalError> {return Future<Bool, InternalError> { [weak self] promise inguard let self = self else { return }self.imManager?.followUser([userId]) { result inpromise(.success(true))} fail: { err, message inlet error = InternalError(error: TIMError.invalidUserId, message: TIMError.invalidUserId.description)promise(.failure(error))}}.eraseToAnyPublisher()}
// File location:TUILiveKit/iOS/TUILiveKit/Source/Service/UserService.swift
func unfollowUser(userId: String) -> AnyPublisher<Bool, InternalError> {return Future<Bool, InternalError> { [weak self] promise inguard let self = self, let imManager = self.imManager else { return }imManager.unfollowUser([userId]) { result inpromise(.success(true))} fail: { err, message inlet error = InternalError(error: TIMError.invalidUserId, message: TIMError.invalidUserId.description)promise(.failure(error))}}.eraseToAnyPublisher()}
// File location:TUILiveKit/iOS/TUILiveKit/Source/Service/UserService.swift
func checkFollowType(userId: String) -> AnyPublisher<V2TIMFollowType, InternalError> {return Future<V2TIMFollowType, InternalError> { [weak self] promise inguard let self = self, let imManager = self.imManager else { return }imManager.checkFollowType([userId], succ: { result inguard let followType = result?.first?.followType else { return }promise(.success(followType))}, fail: { err, message inlet error = InternalError(error: TIMError.invalidUserId, message: TIMError.invalidUserId.description)promise(.failure(error))})}.eraseToAnyPublisher()}
// File location:TUILiveKit/iOS/TUILiveKit/Source/Service/UserService.swift
func fetchFollowersCount(userId: String) -> AnyPublisher<Int, InternalError> {return Future<Int, InternalError> { [weak self] promise inguard let self = self, let imManager = self.imManager else { return }imManager.getUserFollowInfo([userId], succ: { followInfo inlet followersCount = Int(followInfo?.first?.followersCount ?? 0)promise(.success(followersCount))}, fail: { err, message inlet error = InternalError(error: TIMError.invalidUserId, message: TIMError.invalidUserId.description)promise(.failure(error))})}.eraseToAnyPublisher()}
Was this page helpful?