Handler
Handler
Shoplive Short-form에서 발생한 알림을 클라이언트에서 ShopLiveShortformReceiveHandlerDelegate
함수를 통해 전달받고 필요한 처리를 합니다.
protocol ShopLiveShortformReceiveHandlerDelegate : AnyObject {
@objc optional func handleShare(shareUrl: String)
@objc optional func onError(error: Error)
@objc optional func onEvent(command: String, payload: String?)
}
//핸들러 채택하기
class ViewController : ShopLiveShortformReceiveHandlerDelegate {
override func viewDidLoad(){
super.viewDidLoad()
ShopLiveShortform.ShortsReceiveInterface.setHandler(self)
}
}
onEvent(command: String, payload: String?)
Shoplive Short-form 에서 발생하는 여러가지 이벤트를 직접 핸들링 할 수 있는 messageCallback 함수를 제공합니다.
onError(error: Error)
Shoplive Short-form 에서 발생하는 에러를 직접 핸들링 할 수 있는 messageCallback 함수를 제공합니다.
ShortformError Type
type 설명 statusCode 네트워크 응답 상태코드 에러 invalidConfig 숏폼 설정 관련 에러 other 기타 에러 public enum ShortformError: Error { case statusCode(Int) case invalidConfig case other(Error) var errorMessage: String { switch self { case .statusCode(let code): return "[Http status code : statusCode(\(code))] To use Shoplive Short-form, please contact [email protected]" case .invalidConfig: return "[Invalid config] To use Shoplive Short-form, please contact [email protected]" case .other(let error): return "[Other error] \(error.getErrorMsg())" } } }
handleShare(shareUrl: String)
Shoplive Short-form 에서 직접 공유하기 기능을 개발 합니다.
class ViewController : ShopLiveShortformReceiveHandlerDelegate {
func handleShare(shareUrl: String) {
if let url = URL(string : shareUrl) {
//Do something
}
}
}
Updated 13 days ago