iOS 에서의 구루미 OPEN API 사용 가이드 입니다.

👍

최소 요구 사항

  1. iOS 14.3 이상
  2. Privacy - Camera Usage Description 허용 필수
  3. Privacy - Microphone Usage Description 허용 필수
  4. App Transport Security Settings 항목의 Allow Arbitrary Loads 옵션 YES
  5. App Transport Security Settings 항목의 Allow Arbitrary Loads in Web Content 옵션 YES
1280

☁️ WKWebView 설정 (필수)

webView.evaluateJavaScript("navigator.userAgent") { [self] ( userAgent, error ) in
    if let ua = userAgent {
        webView.customUserAgent = "\(ua) BizWebviewApp"
        webView.configuration.applicationNameForUserAgent = "\(ua) BizWebviewApp"
    }
}

// Gooroomee iOS Guide : User-agent
// 
// 1. 기본 User-agent 값에 "BizWebviewApp" 를 추가
// 2. customUserAgent, configuration.applicationNameForUserAgent 양쪽에 모두 추가
// 3. 위 설정이 없는 경우 앱내 웹뷰에서 정상동작하지 않음
//
webView.configuration.allowsInlineMediaPlayback = true
var otpUrl = "https://biz.gooroomee.com/room/otp/biz_7cabdcc0806b4d189648420abed25a3926030ada2bf9418eb3580b48a2"
otpUrl = otpUrl + "?join=true"
if let url = URL(string: otpUrl) {
    let request = URLRequest(url: url)
    webView.load(request)
}

// Gooroomee iOS Guide : OTP URL Parameter
// 
// 1. API 통해 생성된 OTP URL 에 join=true 파라매터를 포함
// 2. 해당 파라매터가 없는 경우 정상 동작하지 않거나 에러 페이지로 리다이렉트됨
//

모바일앱 공통 메세지 가이드

webView.configuration.userContentController.add(self, name: "ioscall")

// Gooroomee iOS Guide : Custom Message Handler Name(WKScriptMessageHandler)
// 
// 1. "ioscall" 이라는 사전 정의 메세지를 통해 JavaScript Message 가 전달됨
// 2. 해당 설정을 하지 않는 경우 이벤트에 대한 스크립트 메세지를 수신하지 못함
//
extension ViewController: WKScriptMessageHandler {
    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        print("message -> " + String(describing: message.body))
        
        let alert = UIAlertController(title: "", message: String(describing: message.body), preferredStyle: .alert)
        self.present(alert, animated: true, completion: nil)
    }
}

// Gooroomee iOS Guide : WKScriptMessageHandler Response Function
// 
// 1. 서버에서 특정 이벤트 발생시 메세지를 받는 인터페이스 함수 설정 (Swift 기본 함수)
// 2. Message Body 정의는 하단 참고 
//
1280

☁️ WKWebView 설정 (옵션)

@available(iOS 15.0, *)
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
    decisionHandler(.grant)
}

// Gooroomee iOS Guide : WKUIDelegate Device Permission
// 
// 1. 위 옵션이 없는 경우에는 웹뷰에 접근시 마다 마이크/카메라의 권한 요청 팝업이 보여짐
// 2. iOS 15 이상의 OS 에서만 가능. 그 이하 버전에서는 매번 마이크/카메라의 권한 요청 팝업이 보여짐 
//