Wishlist
Wishlist Feature allows your users to add items to their wishlist by simply clicking on the wishlist icon. After clicking on the icon an event will be triggered on the SDK, which will confirm the successful or the fail of addition of the item.

This walkthrough shows how to unlock the wishlist feature in your app.
Set Up Product Listener
This walkthrough shows you how to handle Wishlist events in your app. Wishlist events provide insight into what is happening on the Storyly SDK related to the products.
Before you begin
You need to have the working Vertical Feed integration as described in Initial SDK Setup
StorylyView
notifies the application when an event occurs. You can register the listener using the following code example and then override its functions to learn about specific events, which will be explained in the next sections.
verticalFeedView.storylyVerticalFeedProductListener = object : StorylyVerticalFeedProductListener {
// Override event functions
To get notification about these basic events, you should override the following functions.
hydrateWishlist
This function allows you to hydrate your wishlist products.
UpdateWishlistEvent
This function will notify you about updates to the cart in a view
component.
onSuccess
It represents a callback function that will be executed if the "add to wishlist" operation is successful.
let productItem = item
if event == .StoryWishlistAdded {
productItem?.wishlist = true
onSuccess?(productItem)
} else {
productItem?.wishlist = false
onSuccess?(productItem)
}
It represents a callback function that will be executed if the "add to wishlist" or "remove from wishlist" operation is successful.
onFail
onFail?(STRWishlistEventResult(message: "Wishlist update failed. Please try again."))
It represents a callback function that will be executed if the "add to wishlist" or "remove from wishlist" operation fails.
Usage of UpdateWishlistEvent
extension ViewController: StorylyProductDelegate {
func storylyUpdateWishlistEvent(
storylyView: StorylyView,
item: STRProductItem?,
event: StorylyEvent,
onSuccess: ((STRProductItem?) -> Void)?,
onFail: ((STRWishlistEventResult) -> Void)?
) {
let productItem = item
if event == .StoryWishlistAdded {
productItem?.wishlist = true
onSuccess?(productItem)
} else {
productItem?.wishlist = false
onSuccess?(productItem)
}
if event == .StoryWishlistAdded {
print("Shopping StoryWishlistAdded")
// Product is added to wishlist
} else if event == .StoryWishlistRemoved {
print("Shopping StoryWishlistRemoved")
// Product is removed from wishlist
} else if event == .StoryWishlistFailed {
print("Shopping StoryWishlistFailed")
// Wishlist update failed
onFail?(STRWishlistEventResult(message: "Wishlist update failed. Please try again."))
}
// Logging for debug
print("Wishlist Event: \(event)")
print("Wishlist Item: \(String(describing: item))")
}
func storylyHydration(_ storylyView: StorylyView, products: [STRProductInformation]) {
storylyView.hydrateWishlist(products: [])
}
}
Wishlist Hydrate Function
This function provides the list of products that will be used as wishlist items. It is the appropriate place to identify and return the user's wishlist products for hydration.
func storylyHydration(_ storylyView: StorylyView, products: [STRProductInformation]) {
storylyView.hydrateWishlist(products: [])
}
Updated about 24 hours ago