提交
This commit is contained in:
78
TUIKit/TUICallKit/TUICallKit-Swift/Data/Constants.swift
Normal file
78
TUIKit/TUICallKit/TUICallKit-Swift/Data/Constants.swift
Normal file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// Constants.swift
|
||||
// TUICallKit
|
||||
//
|
||||
// Created by vincepzhang on 2022/12/30.
|
||||
//
|
||||
|
||||
// Default avatar
|
||||
let TUI_CALL_DEFAULT_AVATAR: String = "https://imgcache.qq.com/qcloud/public/static//avatar1_100.20191230.png"
|
||||
|
||||
// MARK: Screen Size Param
|
||||
let ScreenSize = UIScreen.main.bounds.size
|
||||
let Screen_Width = UIScreen.main.bounds.size.width
|
||||
let Screen_Height = UIScreen.main.bounds.size.height
|
||||
let StatusBar_Height: CGFloat = {
|
||||
var statusBarHeight: CGFloat = 0
|
||||
if #available(iOS 13.0, *) {
|
||||
statusBarHeight = UIApplication.shared.windows.first?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
|
||||
} else {
|
||||
statusBarHeight = UIApplication.shared.statusBarFrame.height
|
||||
}
|
||||
return statusBarHeight
|
||||
}()
|
||||
let Bottom_SafeHeight = {var bottomSafeHeight: CGFloat = 0
|
||||
if #available(iOS 11.0, *) {
|
||||
let window = UIApplication.shared.windows.first
|
||||
bottomSafeHeight = window?.safeAreaInsets.bottom ?? 0
|
||||
}
|
||||
return bottomSafeHeight
|
||||
}()
|
||||
|
||||
// MARK: FloatWindow UI Param
|
||||
|
||||
let kMicroAudioViewWidth = 88.scaleWidth()
|
||||
let kMicroAudioViewHeight = 88.scaleWidth()
|
||||
let kMicroVideoViewWidth = 110.scaleWidth()
|
||||
let kMicroVideoViewHeight = 196.scaleHeight()
|
||||
let kMicroGroupViewWidth = 88.scaleWidth()
|
||||
let kMicroGroupViewHeight = 106.scaleWidth()
|
||||
|
||||
let kMicroAudioViewRect = CGRect(x: Screen_Width - kMicroAudioViewWidth,
|
||||
y: 150.scaleHeight(),
|
||||
width: kMicroAudioViewWidth,
|
||||
height: kMicroAudioViewHeight)
|
||||
let kMicroVideoViewRect = CGRect(x: Screen_Width - kMicroVideoViewWidth,
|
||||
y: 150.scaleHeight(),
|
||||
width: kMicroVideoViewWidth,
|
||||
height: kMicroVideoViewHeight)
|
||||
let kMicroGroupViewRect = CGRect(x: Screen_Width - kMicroGroupViewWidth,
|
||||
y: 150.scaleHeight(),
|
||||
width: kMicroGroupViewWidth,
|
||||
height: kMicroGroupViewHeight)
|
||||
|
||||
// MARK: UI Size Param
|
||||
let kFloatWindowButtonSize = CGSize(width: 30, height: 30)
|
||||
let kInviteUserButtonSize = CGSize(width: 30, height: 30)
|
||||
|
||||
// MARK: TUICore & IM
|
||||
let TMoreCell_Image_Size = CGSize(width: 65, height: 65)
|
||||
|
||||
let TUI_CALLING_BELL_KEY = "CallingBell"
|
||||
let MAX_USER = 9
|
||||
let ENABLE_MUTEMODE_USERDEFAULT = "ENABLE_MUTEMODE_USERDEFAULT"
|
||||
let TUI_CALLKIT_SIGNALING_MAX_TIME : Int32 = 30
|
||||
|
||||
let kControlBtnSize = CGSize(width: 100.scaleWidth(), height: 94.scaleWidth())
|
||||
let kBtnLargeSize = CGSize(width: 64.scaleWidth(), height: 64.scaleWidth())
|
||||
let kBtnSmallSize = CGSize(width: 60.scaleWidth(), height: 60.scaleWidth())
|
||||
|
||||
class Constants {
|
||||
static let EVENT_SHOW_TUICALLKIT_VIEWCONTROLLER = "eventShowTUICallKitViewController"
|
||||
}
|
||||
|
||||
enum NetworkQualityHint {
|
||||
case None
|
||||
case Local
|
||||
case Remote
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// OfflinePushInfoConfig.swift
|
||||
// TUICallKit
|
||||
//
|
||||
// Created by vincepzhang on 2023/1/6.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import TUICallEngine
|
||||
|
||||
@objc
|
||||
public class OfflinePushInfoConfig: NSObject {
|
||||
@objc
|
||||
public static func createOfflinePushInfo() -> TUIOfflinePushInfo {
|
||||
let pushInfo: TUIOfflinePushInfo = TUIOfflinePushInfo()
|
||||
pushInfo.title = ""
|
||||
pushInfo.desc = TUICallKitLocalize(key: "TUICallKit.have.new.invitation") ?? ""
|
||||
// iOS push type: if you want user VoIP, please modify type to TUICallIOSOfflinePushTypeVoIP
|
||||
pushInfo.iOSPushType = .apns
|
||||
pushInfo.ignoreIOSBadge = false
|
||||
pushInfo.iOSSound = "phone_ringing.mp3"
|
||||
pushInfo.androidSound = "phone_ringing"
|
||||
// VIVO message type: 0-push message, 1-System message(have a higher delivery rate)
|
||||
pushInfo.androidVIVOClassification = 1
|
||||
// HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835
|
||||
pushInfo.androidHuaWeiCategory = "IM"
|
||||
return pushInfo
|
||||
}
|
||||
}
|
||||
95
TUIKit/TUICallKit/TUICallKit-Swift/Data/User.swift
Normal file
95
TUIKit/TUICallKit/TUICallKit-Swift/Data/User.swift
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// User.swift
|
||||
// TUICallKit
|
||||
//
|
||||
// Created by vincepzhang on 2023/1/6.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import ImSDK_Plus
|
||||
import TUICallEngine
|
||||
import TUICore
|
||||
|
||||
enum UserUpdate {
|
||||
case delete(Int)
|
||||
case insert(User, Int)
|
||||
case move(Int, Int)
|
||||
}
|
||||
|
||||
class User {
|
||||
|
||||
let id: Observable<String> = Observable("")
|
||||
let nickname: Observable<String> = Observable("")
|
||||
let avatar: Observable<String> = Observable("")
|
||||
let remark: Observable<String> = Observable("")
|
||||
|
||||
let callRole: Observable<TUICallRole> = Observable(.none)
|
||||
let callStatus: Observable<TUICallStatus> = Observable(.none)
|
||||
|
||||
let audioAvailable: Observable<Bool> = Observable(false)
|
||||
let videoAvailable: Observable<Bool> = Observable(false)
|
||||
let playoutVolume: Observable<Float> = Observable(0)
|
||||
let networkQualityReminder: Observable<Bool> = Observable(false)
|
||||
|
||||
var index: Int = -1
|
||||
|
||||
static func convertUserFromImFullInfo(user: V2TIMGroupMemberFullInfo) -> User {
|
||||
let dstUser = User()
|
||||
dstUser.nickname.value = user.nickName ?? ""
|
||||
dstUser.avatar.value = user.faceURL ?? ""
|
||||
dstUser.id.value = user.userID ?? ""
|
||||
return dstUser
|
||||
}
|
||||
|
||||
static func convertUser(user: V2TIMUserInfo) -> User {
|
||||
return self.convertUser(user: user, volume: 0)
|
||||
}
|
||||
|
||||
static func convertUser(user: V2TIMUserInfo, volume: Float) -> User {
|
||||
let dstUser = User()
|
||||
dstUser.nickname.value = user.nickName ?? ""
|
||||
dstUser.avatar.value = user.faceURL ?? ""
|
||||
dstUser.id.value = user.userID ?? ""
|
||||
dstUser.playoutVolume.value = volume
|
||||
return dstUser
|
||||
}
|
||||
|
||||
static func getUserInfosFromIM(userIDs: [String], response: @escaping ([User]) -> Void ) {
|
||||
V2TIMManager.sharedInstance().getFriendsInfo(userIDs) { friendInfosOptional in
|
||||
guard let friendInfos = friendInfosOptional else { return }
|
||||
var userModels: [User] = Array()
|
||||
for friendInfo in friendInfos {
|
||||
let userModel = convertUser(user: friendInfo.friendInfo.userFullInfo)
|
||||
userModel.remark.value = friendInfo.friendInfo.friendRemark ?? ""
|
||||
userModels.append(userModel)
|
||||
}
|
||||
response(userModels)
|
||||
} fail: { code, message in
|
||||
print("getUsersInfo file code:\(code) message:\(message ?? "") ")
|
||||
}
|
||||
}
|
||||
|
||||
static func getSelfUserInfo(response: @escaping (User) -> Void ){
|
||||
guard let selfId = TUILogin.getUserID() else { return }
|
||||
var selfInfo = User()
|
||||
User.getUserInfosFromIM(userIDs: [selfId]) { users in
|
||||
if let user = users.first {
|
||||
selfInfo = user
|
||||
response(selfInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func getUserDisplayName(user: User) -> String {
|
||||
if !user.remark.value.isEmpty {
|
||||
return user.remark.value
|
||||
}
|
||||
|
||||
if !user.nickname.value.isEmpty {
|
||||
return user.nickname.value
|
||||
}
|
||||
|
||||
return user.id.value
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user