iOS

Mluvii provides a framework for integration with your application. The code provided by us enables you to:

  • initiate a webview with a widget with your company data

  • notification on change of widget status

  • open chat,

  • close the chat and load a page with widget.

Known issue: Due to the unavailability of getUserMedia in in-app WkWebView, video will not connect in Application

If a project downloaded from GitHub does not run because the “MluviiChat” framework cannot be found, we recommend that you recompile the “MluviiChat” project and replace the “MluviiChat.framework” file in the “TestWebkitWebview” project with the newly created “MluviiChat.framework” file.

For best user experience you should add following permissions to your info.plist: Privacy - Camera usage Description Privacy - Microphone usage Description *Privacy - Media Library Usage Description

If you will not add Media Library Usage Description app will crash whe user tries to upload file in mluvii chat

More info onApple Developer Portal

Sample Code:

//
//  ViewController.swift
//  TestWebkitWebview
//
//  Created by Mluvi Mac on 15.03.18.
//  Copyright © 2018 Mluvii. All rights reserved.
//

import UIKit
import WebKit
import MluviiChat

class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate{
    
    //MARK: Properties
    
    @IBOutlet weak var OpenButton: UIButton!
    var webView:WKWebView!
    var widgetState:Int32 = -1
    var chat: MluviiChat? = nil
    
    // Funkce, která zpracovává změnu stavu widgetu
    func statusUpdate(status: Int32) -> Void{
        print("Update status \(status)")
        widgetState = status
        if(widgetState == 0){
            OpenButton.backgroundColor = UIColor.gray
        }else if(widgetState == 1){
            OpenButton.backgroundColor = UIColor.green
        }else if(widgetState == 2){
            OpenButton.backgroundColor = UIColor.orange
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        chat = MluviiChat()
        
        // Nastavení funkce, která určuje, co se má stát při zavření chatu
        chat?.setChatEnded {
            print("Minimize view")
            self.minimizeView()
        }
        
        // Nastavení funkce, která zpracovává změnu stavu
        chat?.setStatusUpdater(statusF: statusUpdate)
        
        // Vytvoření WKWebView, které načte url podle zadaného serveru, company GUID, tenant ID, preset name a požadovaného jazyku
        // url, companyGuid a tenantId jsou povinné proměnné, presetName a language můžou být nil
        webView = chat?.createWebView(url: "ptr.mluvii.com", companyGuid: "295b1064-cf5b-4a5d-9e05-e7a74f86ae5e", tenantId: "1", presetName: nil, language: nil)
        self.view.addSubview(webView)
    }
    
    // Funkce, která otevře chat ve WebView a maximalizuje ho
    func maximizeWebView(){
        chat?.openChat()
    }
    
    // Funkce, která nastaví rozměry webView na 0,0 a změní url zpět na požadovaný widget
    func minimizeView(){
        chat?.resetUrl()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        print("Did receive memory warning")
    }
    
    
    //MARK: Actions

    @IBAction func TouchInside(_ sender: Any) {
        if(widgetState != -1){
            maximizeWebView()
        }
    }
    /**/
}

results matching ""

    No results matching ""