iOS v2 Chat SDK Swift UI
投稿日時:2022年2月03日
This may seem like a stupid question but how on earth can I change the color of the Navigation Bar from blue to anything else? Our app uses Swift UI so here is the code I used:
import SwiftUI
import UIKit
import ChatSDK
import ChatProvidersSDK
import MessagingSDK
struct CustomerSupport: View {
var body: some View {
MessagingView()
}
}
struct CustomerSupport_Previews: PreviewProvider {
static var previews: some View {
CustomerSupport()
}
}
struct MessagingView: UIViewControllerRepresentable {
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
print("View Updated")
}
func makeUIViewController(context: Context) -> UIViewController {
let formConfiguration = ChatFormConfiguration(name: .hidden,
email: .optional,
phoneNumber: .hidden,
department: .hidden)
let chatConfiguration = ChatConfiguration()
chatConfiguration.isAgentAvailabilityEnabled = false
chatConfiguration.preChatFormConfiguration = formConfiguration
let messagingConfiguration = MessagingConfiguration()
messagingConfiguration.name = "Bismillah Support"
let visitorInfo = VisitorInfo(name: usersProfile.name ?? "", email: currentUser.email ?? "", phoneNumber: currentUser.phoneNumber)
Chat.profileProvider?.setVisitorInfo(visitorInfo, completion: { result in
switch result {
case .success(_):
print("User info set")
case .failure(let error):
print(error)
}
})
do {
let chatEngine = try ChatEngine.engine()
let viewController = try Messaging.instance.buildUI(engines: [chatEngine], configs: [chatConfiguration, messagingConfiguration])
return UINavigationController(rootViewController: viewController)
} catch {
return UIViewController()// handle error
}
}
//...
}
0
5
0件のコメント
サインインしてコメントを残してください。