Mesibo чат SDK интегрировать в IOS с помощью Swift
Я устанавливаю mesibo
чат sdk. auth key generated and set it to
Appdelegate.Create` пользователь в панели инструментов Mesibo и пытается отправлять или получать сообщения, но не может получить никаких сообщений. Ошибка отображения на приборной панели:-
msgstr "не удалось отправить сообщения".
Используйте Mesibo Framework a. Реализовать методы делегата для этого.
Appdelegate
код в дидфиниш запустить.
Mesibo.getInstance()!.setAccessToken("1c06e8813355b567b0f79162d5ff786e96b419122ade88ef68")
Mesibo.getInstance()!.setSecureConnection(true)
Mesibo.getInstance()!.start()
Код в поле зрения контроллера:-
MesiboUI.launchMessageViewController(self, profile:nil)
Mesibo.getInstance()?.start()
Я ожидаю мгновенного чата от одного до одного.
1 ответ
Попробуйте добавить слушателя в методе didFinishLaunching:
[MesiboInstance addListener: self];
**Please check in Appdelegate :
mesiboInstance?.setAccessToken("youraccesstoken")
Mesibo.getInstance()?.addListener(self)
Mesibo.getInstance()?.start()
//MARK:- Get user permission for using camera , audio
extension AppDelegate {
func checkCameraAccess() {
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .denied:
print("Denied, request permission from settings line 288")
//presentCameraSettings()
case .restricted:
print("Restricted, device owner must approve line 291")
case .authorized:
print("Authorized, proceed line 293")
case .notDetermined:
AVCaptureDevice.requestAccess(for: .video) { success in
if success {
print("Permission granted, proceed line 297")
} else {
print("Permission denied")
}
}
}
}
func checkMicPermission() {
switch AVAudioSession.sharedInstance().recordPermission {
case AVAudioSession.RecordPermission.granted:
print("mic Permission granted , line 305")
break
case AVAudioSession.RecordPermission.denied:
print("mic Permission not granted , line 309")
break
case AVAudioSession.RecordPermission.undetermined:
AVAudioSession.sharedInstance().requestRecordPermission({ (granted) in
if granted {
print("mic Permission granted , line 312")
} else {
print("mic Permission denied , line 314")
}
})
default:
break
}
}
}
extension AppDelegate {
func setRootController(_ controller: UIViewController?) {
window!.rootViewController = controller
window!.rootViewController = controller
window!.makeKeyAndVisible()
//[[UIApplication sharedApplication].keyWindow setRootViewController:rootViewController];
}
public func mesibo_(onGetMenu parent: Any!, type: Int32, profile: MesiboUserProfile!) -> [Any]! {
var btns: [AnyHashable]? = nil
if type == 0 {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "ic_message_white"), for: .normal)
button.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
button.tag = 0
let button1 = UIButton(type: .custom)
button1.setImage(UIImage(named: "ic_more_vert_white"), for: .normal)
button1.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
button1.tag = 1
btns = [button, button1]
} else {
if profile != nil && profile?.address != nil {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "ic_call_white"), for: .normal)
button.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
button.tag = 0
let vbutton = UIButton(type: .custom)
vbutton.setImage(UIImage(named: "ic_videocam_white"), for: .normal)
vbutton.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
vbutton.tag = 1
btns = [vbutton, button]
}
}
return btns
}
public func mesibo_(onMenuItemSelected parent: Any!, type: Int32, profile: MesiboUserProfile!, item: Int32) -> Bool {
// userlist menu are active
if type == 0 {
// USERLIST
if item == 1 {
//item == 0 is reserved
// MesiboUIManager.launchSettings(parent as! UIViewController)
}
} else {
// MESSAGEBOX
if item == 0 {
print("Menu btn from messagebox pressed")
MesiboCall.sharedInstance().call(parent, callid: 0, address: profile?.address, video: false, incoming: false)
} else if item == 1 {
DispatchQueue.main.async(execute: {
MesiboCall.sharedInstance().call(parent, callid: 0, address: profile?.address, video: true, incoming: false)
})
}
}
return true
}
}
In your view controller
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//Set user here
let profile : MesiboUserProfile = MesiboUserProfile()
profile.address = "youremail@email.com"
MesiboUI.launchMessageViewController(self, profile: profile)
}
}