REES46 SDK is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'REES46'
If you are using Xcode 11 or later:
File
Swift Packages
Add Package Dependency...
https://github.com/rees46/ios-sdk.git
SDK is used for several tasks:
Initialize SDK object and use it anywhere in your application. (!) Remember to initialize SDK only once on application launch.
import REES46
.....
var sdk = createPersonalizationSDK(shopId: "API_KEY")
Or with completion to handle problems:
import REES46
.....
sdk = createPersonalizationSDK(shopId: "API_KEY", { (error) in
print(error)
})
Track user's behavior to collect data. There are several types of events:
// Common view
sdk.track(event: .productView(id: "PRODUCT_ID")) { _ in
print("Product view callback")
}
// From instant search
sdk.track(event: .productView(id: "PRODUCT_ID"), recommendedBy: 'instant_search') { _ in
print("Product view callback")
}
// From full search
sdk.track(event: .productView(id: "PRODUCT_ID"), recommendedBy: 'full_search') { _ in
print("Product view callback")
}
// From recommender block - use block ID for recommendedBy parameter
sdk.track(event: .productView(id: "PRODUCT_ID"), recommendedBy: 'WTJc23B2pTBsgc0e') { _ in
print("Product view callback")
}
sdk.track(event: .categoryView(id: "CATEGORY_ID")) { _ in
print("Category view callback")
}
sdk.track(event: .productAddedToFavorities(id: "PRODUCT_ID")) { _ in
print("Product is added to wish list callback")
}
sdk.track(event: .productRemovedToFavorities(id: "PRODUCT_ID")) { _ in
print("Product is removed from wish list callback")
}
sdk.track(event: .productAddedToCart(id: "PRODUCT_ID")) { _ in
print("Product is added to cart callback")
}
Also supports
recommendedBy
parameter
sdk.track(event: .productRemovedFromCart(id: "PRODUCT_ID")) { _ in
print("Product is removed from cart callback")
}
This method is used to override current state of user's shopping cart. It's easier to sync cart with API using this method, than productAddedToCart
and productRemovedFromCart
methods.
sdk.track(event: .synchronizeCart(items: [CartItem(productId: "784"), CartItem(productId: "785", quantity: 3)] )) { _ in
print("Cart is synced callback")
}
sdk.track(event: .orderCreated(orderId: "ORDER_ID", totalValue: 33.3, products: [(id: "PRODUCT_1_ID", amount: 3), (id: "PRODUCT_2_ID", amount: 1)])) { _ in
print("Order is created callback")
}
You can use recommender engine in two ways:
sdk.recommend(blockId: "BLOCK_ID") { recommendResult in
print("Callback")
}
For example, you can provide current product ID (to exclude it from recommended products when user sees this product's details page):
sdk.recommend(blockId: "block_id", currentProductId: "PRODUCT_ID") { recommendResult in
print("Callback")
}
We have 2 types of search:
sdk.suggest(query: "ipho") { searchResult in
print("Suggest callback")
}
Full search can be performed as simple query and query with filter parameters.
Simple full search:
sdk.search(query: "iphone") { searchResult in
print("Full search callback")
}
Full search with additional filters:
sdk.search(query: "laptop", limit: nil, offset: nil, categoryLimit: nil, categories: nil, extended: nil, sortBy: nil, sortDir: nil, locations: nil, brands: nil, filters: nil, priceMin: nil, priceMax: nil, colors: nil, exclude: nil) { searchResult in
print("Full search callback")
}
Parameters list:
Parameter | Required | Description |
---|---|---|
query | true | Search query |
limit | false | Limit of results |
offset | false | Offset of results |
categoryLimit | false | How many categories for sidebar filter to return |
categories | false | Dictionary categories list to filter products by |
extended | false | It's better to use true for full search results |
sortBy | false | Sort by parameter: popular , price , discount |
sortDir | false | Sort direction: asc or desc (default) |
locations | false | Dictionary list of locations IDs |
brands | false | Dictionary list of brands to filter |
filters | false | JSON object with filter parameters. For example: ["bluetooth":["yes"],"offers":["15% cashback"],"weight":["1.6"]] |
priceMin | false | Min price |
priceMax | false | Max price |
colors | false | Dictionary list of colors |
exclude | false | Dictionary list of products IDs to exclude from search results |
Output:
categories = [Category];
products = [Product];
productsTotal = Int;
queries = [Query];
You can populate user's profile with additional data.
For example, save email to user's profile:
sdk.setProfileData(userEmail: "[email protected]") { (profileDataResp) in
print("Profile data callback")
}
Or you can provide more data:
sdk.setProfileData(userEmail: "[email protected]", userPhone: "+111111111111", userLoyaltyId: "LOYALTY_CARD_ID", birthday: nil, age: nil, firstName: "Johny", lastName: "Cash", location: nil, gender: .male) { (profileDataResp) in
print("Profile data callback")
}
sdk.setPushTokenNotification(token: "TOKEN_STRING") { (tokenResponse) in
print("Token set response")
}
sdk.review(rate: 5, channel: "ios_app", category: "delivery", comment: "Nice application, thank you!") { (reviewResponse) in
print("Review is saved")
}
Parameters list:
Parameter | Required | Description |
---|---|---|
rate | true | Score of the rated process. Value between 1 - 10 |
channel | true | NPS channel code |
category | true | NPS process category code |
comment | false | Optional answer to the follow-up question |
orderId | false | Order ID, related to the current survey |
These method are used for debug tasks. You don't need it for common tasks.
let deviceID = sdk.getDeviceID()
REES46, [email protected]
REES46 SDK is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 0 |
Last commit: 8 hours ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics