Javascript Interfaces in SDK

SDK exposes Javascript Interfaces to support functionalities that uses WebView.

Hybrid Engagement

SDK lets you start a native Chat from a Business Rule running within a WKWebView. SDK handles all the necessary communication between JavaScript and Native.

Nuance Business Rule engine loaded within a WebView page executes the Business Rule for that page upon page load. C2C button is displayed on the page if BR engine finds a match.

If user decides to click the C2C button, Nuance BR engine redirects the engagment request to Native Nuance SDK.

Public Methods

You must call the below NuanMessaging public method to enable this bridge between javascript and Native SDK.

Conversation in Play

If there is a pending message from agent pendingMsgHandler will be called with a c2c id. Application should be displaying a restore button. Upon user clicking the restore button applciation should call below API

Public Methods

You must call the below NuanMessaging public method when user clicks restore button.


	let contentController = WKUserContentController()
        contentController.add(
            self,
            name: NuanMessaging.getInstance().getWKWebViewInterfaceName()
        )

	
	func userContentController(_ userContentController:WKUserContentController, didReceive message: WKScriptMessage) {
	 if(message.name == NuanMessaging.getInstance().getWKWebViewInterfaceName()) {
        NuanMessaging.getInstance().handleWebviewRequest(message.body as! String, andNewEngagementHandler: { (params, datapass) in
            
          var vc:NuanceMessagingViewController;
                
                
          vc = launchMessagingViewControllerForHybrid(paramsDict: (params as? Dictionary)!,dataPass: (datapass as? Dictionary)!,  webview: self.webView)

          self.setupMessagingUIProps(vc: vc)
          
          DispatchQueue.main.async {
              
              self.present(vc, animated: false, completion: nil)
          }


        }, andEvaluateJSHandler: { (js) in
            self.webView.evaluateJavaScript(js!, completionHandler: nil)
        }, andPendingMsgHandler: { (c2cidx) in
                
            });
      
        
    }
	}



Nina WebView SDK

Nuance SDK lets Application to use Nina WebView SDK within Nuance Messaging SDK. Nuance Messaging SDK uses Nina WebView SDK to render rich html transcript contents returned from Nina Virtual Assitant.

Nina WebView SDK is not preloaded inside the SDK. It must be added by the application. Assets are provided as part of SDK deliverable

Configuring Nina WebView SDK
Properties to customize Nina SDK is exposed from MessagingViewProperties class.
Name type default description
isNinaWebRequired boolean false Set this property to enable Nina WebView SDK
htmlFileUrlPathForTranscript URL nil Pass the url to the Nina WebView asset. Bundle.main.url(forResource: "index", withExtension: "html")