I have a problem and that is i'm trying to put Smooch's chat UI but this is always displayed in fullscreen mode in iPhone 6s. Can someone help me?
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "popoverSegue" {
// Get the new view controller using segue.destinationViewController.
let popoverViewController: SmoochViewController = segue.destination as! SmoochViewController
//popoverViewController.newViewController = Smooch.newConversationViewController()
popoverViewController.modalPresentationStyle = UIModalPresentationStyle.popover
popoverViewController.popoverPresentationController!.delegate = self
}
}
This is how I'm trying to present SmoochViewController which displays the chat.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Adding some values to the user
SKTUser.current()!.firstName = "Kevin" // User's first name
SKTUser.current()!.lastName = "Bustillos Acurio" // User's lastname
SKTUser.current()!.email = "kevinbustillos21@hotmail.com" // User's email
SKTUser.current()!.signedUpAt = Date() // User's sign in date
let conversation: SKTConversation = Smooch.conversation()!
// Debugging messages (can be deleted)
for message in conversation.messages! {
print("MESSAGES \((message as! SKTMessage).text)")
}
let newViewController: UIViewController = Smooch.newConversationViewController()!
// Display Smooch UI (it displays the UI, the messages, avatars, all...)
Smooch.showConversation(from: newViewController)
// Just for debugging
print("USER ID \(SKTUser.current()!.userId)")
print("SMOOCH ID \(SKTUser.current()!.smoochId)")
print("CURRENT USER FIRST NAME: \(SKTUser.current()!.firstName)")
print("CURRENT USER LASTNAME: \(SKTUser.current()!.lastName)")
print("CURRENT USER EMAIL: \(SKTUser.current()!.email)")
print("CURRENT USER DATE: \(SKTUser.current()!.signedUpAt)")
}
And this is how I'm trying to present the chat in a different UIViewController
Thanks!
The default display mode for popovers on iPhone is to take the full screen. If you want a true popover, you'll need to implement the adaptivePresentationStyle(for:)
method and return .none
https://rbnsn.me/ios-8-popover-presentations
I was able to get the view controller to appear in a popover using this code
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let newViewController: UIViewController = Smooch.newConversationViewController()!
newViewController.modalPresentationStyle = .popover
newViewController.popoverPresentationController!.delegate = self
newViewController.popoverPresentationController!.sourceView = self.view
self.present(newViewController, animated: true, completion: nil)
}
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
However, the text input doesn't play very nicely with the keyboard when presented in this way, so it might be better to present it fullscreen after all
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.