- Print
Native integration
- Print
Integrate with code
CocoaPods
Add the below code to Podfile
.
Swift Package Manager
Add the following contents to Package Dependencies
.
Delete the cache if installation is failed
Execute the following command in the terminal to delete the cache.
rm -rf ~/Library/Caches/org.swift.swiftpm rm -rf ~/Library/org.swift.swiftpm
Apply AccessKey
import ShopliveSDKCommon
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
ShopLiveCommon.setAccessKey(accessKey: "YOUR_ACCESSKEY") //required
return true
}
}
Access Key
Access key and secret key can be obtained from Shoplive representative
Apply Native Shortform Collection
Apply the desired Shortform Collection.
ShopLiveShortformCardTypeView
For Vertical Scroll Layout (Large Content Grid), add the ShopLiveShortformCardTypeView
.
ShopLiveShortformVerticalTypeView
For Vertical Scroll Layout (Small Content Grid), add the ShopLiveShortformVerticalTypeView
.
import ShopLiveShortformSDK
class ViewController : UIViewController {
private var builder = ShopLiveShortform.ListViewBuilder()
lazy private var verticalTypeView : UIView = {
let verticalTypeView = builder.build(cardViewType: .type1,
listViewType: .vertical,
enableSnap: true,
enablePlayVideo: true,
playOnlyOnWifi: false,
cellSpacing: 20,
avAudioSessionCategoryOptions : .mixWithOthers).getView()
builder.submit()
return verticalTypeView
}()
override func viewDidLoad(){
super.viewDidLoad()
view.addSubView(verticalTypeView)
//set constraints
verticalTypeView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
verticalTypeView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
verticalTypeView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
verticalTypeView.widthAnchor.constraint(equalToConstant: {YOUR_WIDTH}),
verticalTypeView.heightAnchor.constraint(equalToConstant: {YOUR_HEIGHT})
])
}
}
ShopLiveShortformHorizontalTypeView
For Horizontal Scroll Layout, add the ShopLiveShortformHorizontalTypeView
.
import ShopLiveShortformSDK
class ViewController : UIViewController {
private var builder = ShopLiveShortform.ListViewBuilder()
lazy private var horizontalTypeView : UIView = {
let horizontalTypeView = builder.build(cardViewType: .type1,
listViewType: .horizontal,
enableSnap: true,
enablePlayVideo: true,
playOnlyOnWifi: false,
cellSpacing: 20,
avAudioSessionCategoryOptions : .mixWithOthers).getView()
builder.submit()
return horizontalTypeView
}()
override func viewDidLoad(){
super.viewDidLoad()
view.addSubView(horizontalTypeView)
//set constraints
horizontalTypeView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
horizontalTypeView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
horizontalTypeView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
horizontalTypeView.widthAnchor.constraint(equalToConstant: {YOUR_WIDTH}),
horizontalTypeView.heightAnchor.constraint(equalToConstant: {YOUR_HEIGHT})
])
}
}
View settings
When constructing a View in a list, you can set the following properties using a builder
View Activation
Activate the view using a builder and load the data by invoking submit()
function. (If submit()
function is not called, the data will not be loaded, and the list view will not be configured on the screen.)
Card View type configuration
Configure card-type layout
.type0
: No product card on the collection view.type1
: Square product card on the collection view.type2
: Circle product card on the collection view
Refer to the following example:
Type0
Type1
Type2
Tag-Based Collection View
You can search by HashTag:
ShopLiveTagSearchOperator.OR
: HashTag unified search (Default)ShopLiveTagSearchOperator.AND
: HashTag cross-search
Brand-Based Collection View
You can search by brand (either brand name or identifier)
Shuffled Collection View
Display data in random order or by most recent time.
enableShuffle()
: Display random datadisableShuffle()
Display data by most recent time
Enable Snap effect
Use snap effects to highlight individual content.
enableSnap()
: Enable snap effectdisableSnap()
: Disable snap effect (Default)
Shortform playback range (Horizontal Layout Only)
You can select which cells to render in the horizontal scroll.
ShopLiveShortform.PlayableType.First
: Only the leftmost cell in the visible area is rendered. (Default)ShopLiveShortform.PlayableType.Center
: Only the center cell in the visible area is rendered.ShopLiveShortform.PlayableType.All
: Entire cell in the visible area is rendered.
Configure video autoplay effects
Configure whether to autoplay videos in cells.
enablePlayVideos()
: Enable autoplay videos in cells. (Default)disablePlayVideos()
: Disable autoplay videos in cells.
Scroll to the top.
Go to the top of the page.
Set videos to play only on Wi-Fi
Configure video playback to occur only when connected to Wi-Fi:
true
: Playback only when connected to Wi-Fifalse
: Playback on any network (Default)
Set item spacing
Configure the spacing between items
Data refresh
Refresh the data
Hide view count
Hide the view indicating the number of views (Default: visible)
Hide product count
Hide the view indicating the number of products (Default: visible)
Hide brand
Hide the brand view (Default: visible)
Hide title
Hide title (Default: visible)
Hide description
Hide the description (Default: visible)
Set the corner radius of cells
Configure the cornerRadius of cells (Default: 6px)
Set cell placeholder color
Configure the default value for cell placeholders (Default: CBCBCB)
Screen rotation event propagation
You can call the builder?.notifyViewRotated()
function when the superview of the list view is rotated to redraw its layout
ListViewDelegate settings
You can receive and process notifications from its list view through the ShopLiveShortformListViewDelegate
.
ShopLiveShortformListViewDelegate
consists of the following 1 function.
Error handling function
You can handle errors occurring in the list view through onListViewError(error: Error)