하이브리드 연동
- 인쇄
하이브리드 연동
- 인쇄
기사 요약
이 요약이 도움이 되었나요?
의견을 보내 주셔서 감사합니다.
코드 설치
CocoaPods
Podfile
에 아래 코드를 추가하세요.
Swift Package Manager
Package Dependencies
에 다음 내용을 추가하세요
설치가 실패한다면 캐시를 지웁니다
터미널에서 다음 커맨드를 실행하여, 캐시를 삭제해주세요.
rm -rf ~/Library/Caches/org.swift.swiftpm rm -rf ~/Library/org.swift.swiftpm
웹 연동
숏폼을 서비스하기 위해 웹 연동이 우선 진행되어야 합니다. 웹 연동을 위해 다음 링크를 참고 해주세요.
네이티브 코드 적용
고객사 웹 UIViewController
에 아래 코드를 추가하세요.
Handler 가이드를 참고하세요.
ShopLiveShortform.BridgeInterface
Webview를 BridgeInterface
에 연결만으로 다음과 같은 기능이 제공됩니다.
상품화면을 나가면 자동으로 preview를 종료합니다.
숏폼 미리보기, 보기, 닫기가 동작합니다.
// Connect Webview to BridgeInterface
ShopLiveShortform.BridgeInterface.connect(webview) // Required
ShopLiveShortform.Delegate
고객사 웹 UIViewController
에 Delegate를 통해서 ShopLiveShortformReceiveHandlerDelegate
를 설정하면, 다음과 같은 callback을 사용할 수 있습니다.
public protocol ShopLiveShortformReceiveHandlerDelegate: AnyObject {
// 공유하기 버튼을 눌렀을 때, 공유 URL을 전달합니다.
func handleShare(shareUrl: String)
func handleShare(shareMetadata : ShopLiveShareMetaData)
// 에러가 발생하면 에러를 전달합니다. 기본적으로 error는 ShopLiveCommonError:Error로 내려갑니다.
func onError(error: Error)
// 숏폼에서 발생한 이벤트를 전달합니다.
func onEvent(command: String, payload: String?)
// 숏폼 화면의 닫힘 이벤트를 전달합니다.
func onDidDisAppear()
// 숏폼 화면의 열림 이벤트를 전달합니다.
func onDidAppear()
// 상품의 클릭 이벤트를 전달합니다.
func handleProductItem(shortsId : String, shortsSrn : String, product : ProductData)
// 상품 배너의 클릭 이벤트를 전달합니다.
func handleProductBanner(shortsId : String, shortsSrn : String, scheme : String, shortsDetail : ShortsDetailData)
}