このユーザーガイドでは、ストーリーボードUIにAlli iOS SDKを統合する方法について説明します。 Alli SDKにはiOS 10以降が必要です。
AlliFramework.frameworkフォルダーのinfo.plistファイルを開き、情報プロパティリストの横にある「+」記号をクリックします。 ドロップダウンリストを[プライバシー]オプションまでスクロールし、カメラにアクセスするための[プライバシーカメラ使用法の説明]またはフォトライブラリにアクセスするためのプライバシーフォトライブラリ使用法の説明を選択します。
これにより、ユーザーは領収書ファイルまたは製品画像をチャットにアップロードできます。
選択した後、右側の文字列値を入力して、警告ポップアップが許可を求めたときにユーザーに表示するテキストを含めます。
※以下の画像には”YOUR_API_Key”と記載がありますが、こちらにSDKキーを記載ください。
var alli: Alli?
override func viewDidLoad() {
// showHeader - optional, default: true, If you want to remove the header, turn off this option.
// showFooter - optional, default: true, If you want to remove the footer, turn off this option.
// showBackButton - optional, default: true, If you want to remove the back button on the header, turn off this option.
alli = Alli("YOUR_API_Key", eventHandler: self, showHeader: true, showFooter: true, showBackButton: false)
}
AndroidSDK用のJavascripSDKで使用可能なすべてのパラメーターも使用できます。
Dictionary <String、Any>を使用して、JavascriptSDKの初期化に使用されるパラメーターをinitWithParams引数に送信します。
alli = Alli.initWithParams("YOUR_API_Key", eventHandler: self,
params: [
"header": true,
"footer": true,
"backButton": true,
"styleOptions": ["conversationContainer": [
"right": 50,
"left": 50,
"bottom": 50]]])
SDKキーは、左側のナビゲーションから[設定]>[全般]をクリックし、プロジェクト設定ページSDKキーを取得してください。
ユーザーとAlliが会話することができるダイアログを作成するには、下記を呼び出します。
alli!.event(view: parentView)
特定のユーザIDとPlacementを指定したい場合は以下のように呼び出します。
alli!.event(userId:"YOUR_userId", placement:"YOUR_placement", view:parentView)
サービスにログインして、ユーザが特定されている場合、上記のようにAlliに情報を渡すことができます。あるいはログインしていないユーザーのために、一時的なIDを生成することもできます。
Placement情報は、ユーザーにスキルを表示したいアプリ内の場所を決定するために使用されます。Placementを作成した後、Alliダッシュボードで必要なスキルにPlacementを指定することができます。この機能の利点は、プレースメントに表示するスキルをいつでも決定できることです。
Alliダイアログは、親ビューコントローラで実装する必要があります。このとき、親ビューコントローラを委任属性に割り当てる必要があります。この呼び出しに渡されたViewControllerが最上位のビューであり、他のビューに隠れないようにしてください。そして親ビューは、最小の高さと幅が必要です。
initWithParamsと同じように、eventWithParamsを用いることで、すべての使用可能なJavascriptパラメーターが使用できます。
alli!.eventWithParams(view: innerView,
params: [
"user": ["id": "YOUR_userId"],
"placement": "YOUR_placement",
"variables": ["test": "test value",
"AGE": 31,
"BIRTHDAY": "2021-06-30",
"boolean": true]])
※上記のuserIdの形式にご注意ください。
次のデリゲートメソッドは、チャットの会話ステータスに関するフィードバックを提供します。
import WebKit
public protocol AlliEventHandler {
// Called when initialized successfully.
// You may receive NOT_INITIALIZE_YET error if
// called before this event.
func onInitialized(_ view:WKWebView!)
// Called when chat started successfully.
func onConversationStarted(_ view: WKWebView!, userId: String, placement: String, context: Any?)
// Called when conversation did not start
// even when Alli.event was called.
func onConversationNotStarted(_ view: WKWebView!, userId: String, placement: String, context: Any?)
// Called when user has closed the chat
// window or Alli.close() is called.
func onConversationStopped(_ view: WKWebView!, userId: String, placement: String, context: Any?)
func onError(_ view: WKWebView!, errorCode: AlliErrorCode, userId:String?, placement:String?, context:Any?)
}
Alliチャットでhttpまたはhttpsにリンクすると、顧客のデフォルトのブラウザーが起動します。 他のアプリケーションへのリンクを追加する場合は、AlliEventHandlerからhandleUrlLoadingメソッドを実装します。
func handleUrlLoading(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
let strUrl = navigationAction.request.url!.absoluteString
if() {
UIApplication.shared.open(URL(string: strUrl)!, options: [:], completionHandler: nil)
decisionHandler(.allow)
}
else {
decisionHandler(.cancel)
}
}
(例)Apple Mapを起動する場合
let strUrl = "http://maps.apple.com/?q=seoul"
ISO/IEC 27001
certified