Implementing the Brand Likes and Follows feature
- Print
Implementing the Brand Likes and Follows feature
- Print
Article summary
Did you find this summary helpful?
Thank you for your feedback
In Shoplive Player, you can use the function to like (follow) brands registered by your customers. If you activate this function, a like (follow) button along with the brand image will be displayed within the Shoplive Player. The status of the button is synced to the customer data set by the customer company.
In order to integrate this function, consultation with Shop Live is required. For further details, please contact to ShopLive at ask@shoplive.cloud to enable this feature.
Display the Brand likes (follow) button
var user = ShopLiveCommonuser(userId : "harry", name : "potter", custom : ["key" : "AnyType value"])
ShopLive.user = user
Callback for the Brand likes (follow) button click event
func handleReceivedCommand(_ command: String, with payload: Any?) {
switch command {
case "ON_CHANGED_BRAND_FAVORITE":
guard let parameters = payload as? [String: Any],
let favorite = parameters["favorite"] as? Bool,
let identifier = parameters["identifier"] as? String else {
return
}
print("[command = ON_CHANGED_BRAND_FAVORITE] \n identifier: \(identifier)\nfavorite \(favorite)")
break
case "ON_CLICK_BRAND_FAVORITE_BUTTON":
guard let parameters = payload as? [String: Any],
let favorite = parameters["favorite"] as? Bool,
let identifier = parameters["identifier"] as? String else {
return
}
print("[command = ON_CLICK_BRAND_FAVORITE_BUTTON] \n identifier: \(identifier)\nfavorite \(favorite)")
break
default:
break
}
}
Pass the settings of the Brand likes (follow) to Shoplive Player
You can sync the brand like (follow) status by sending the user's brand like (follow) status to the Shoplive Player.
let result = ["identifier" : "brand-identifier", "favorite" : false]
ShopLive.sendCommandMessage(command: "SET_BRAND_FAVORITE", payload: result)