Mesibo Chat SDK使用SWIFT集成在iOS中



我正在设置 mesibo chat sdk. auth key generated and set it to appdelegate.create`Mesibo仪表板中的用户,并尝试发送或接收消息,但无法收到任何消息。仪表板上显示错误: -

"无法发送消息"。

使用Mesibo Framework A. Implement委托方法。

Appdelegate在didfinish启动中代码。

Mesibo.getInstance()!.setAccessToken("1c06e8813355b567b0f79162d5ff786e96b419122ade88ef68")
Mesibo.getInstance()!.setSecureConnection(true)
Mesibo.getInstance()!.start()

查看控制器中的代码: -

MesiboUI.launchMessageViewController(self, profile:nil)
Mesibo.getInstance()?.start()

我希望即时聊天从一个到一个。

尝试在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)
    }
}

最新更新