iOS Targeting Actions
In-App Messaging
In-app messages are notifications to your users when they are directly active in your mobile app. To enable In-App Messaging feature you need to set the value of inAppNotificationsEnabled
parameter when calling createAPI
to initialize the SDK.
import VisilabsIOS
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Visilabs.createAPI(organizationId: "YOUR_ORGANIZATION_ID", profileId: "YOUR_PROFILE_ID"
, dataSource: "YOUR_DATASOURCE", inAppNotificationsEnabled: true, channel: "IOS"
, requestTimeoutInSeconds: 30, geofenceEnabled: false, maxGeofenceCount: 20)
return true
}
The existence of a relevant in-app message for an event controlled by after each customEvent
call. You can create and customize your in-app messages on https://intelligence.relateddigital.com/#Target/TargetingAction/TAList page of RMC administration panel.
There are 9 types of in-app messages:
Pop-up - Image, Header, Text & Button | Mini - Icon & Text | Full Screen-image |
|
|
|
Full Screen-image&button | Pop-up - Image, Header, Text & Button | Pop-up-Survey |
|
|
|
Pop-up - NPS with Text & Button | Native Alert & Action Sheet | NPS with Number |
|
|
|
NPS & Second Popup | Video In-App |
|
|
|
|
If you want to manage the links you add for in-app messages yourself, you can follow the step below.
First you have to call the delegate method
Visilabs.callAPI().inappButtonDelegate = self
Then you have to add the extension and you can delete the print codes and write your own codes.
extension EventViewController: VisilabsInappButtonDelegate {
func didTapButton(_ notification: VisilabsInAppNotification) {
print("notification did tapped...")
print(notification)
}
}
Favorite Attribute Actions
You can access favorite attributes of the Targeting Actions of type Favorite Attribute Action that you defined from the https://intelligence.relateddigital.com/#Target/TargetingAction/TAList/ section on the RMC panel via the mobile application as follows.
Visilabs.callAPI().getFavoriteAttributeActions { (response) in
if let error = response.error {
print(error)
} else {
if let favoriteBrands = response.favorites[.brand] {
for brand in favoriteBrands {
print(brand)
}
}
if let favoriteCategories = response.favorites[.category] {
for category in favoriteCategories {
print(category)
}
}
}
}
You can also access favorite attributes of a particular Targeting Action by specifying the ID.
Visilabs.callAPI().getFavoriteAttributeActions(actionId: 188) { (response) in
if let error = response.error {
print(error)
} else {
if let favoriteBrands = response.favorites[.brand] {
for brand in favoriteBrands {
print(brand)
}
}
if let favoriteCategories = response.favorites[.category] {
for category in favoriteCategories {
print(category)
}
}
}
}
favorites
property of response
object is a dictionary which has an enum
as key and an array
of String
s as value. The cases of VisilabsFavoriteAttribute
enum
are the followings:
public enum VisilabsFavoriteAttribute: String {
case ageGroup
case attr1
case attr2
case attr3
case attr4
case attr5
case attr6
case attr7
case attr8
case attr9
case attr10
case brand
case category
case color
case gender
case material
case title
}
Story Actions
Story actions allow you to add widgets similar to "Instagram Story" list view on your iOS devices. getStoryView
method returns an instance of VisilabsStoryHomeView
which is a subclass of UIView
.
let storyView = Visilabs.callAPI().getStoryView()
view.addSubview(storyHomeView)
You can also access a story action by specifying the ID of the Targeting Action.
let storyView = Visilabs.callAPI().getStoryView(actionId: 67)
view.addSubview(storyHomeView)
Mail Subscription Form
After form is created at RMC panel, likewise in-app message, existence of mail subscription form is controlled by after each customEvent
call. It is shown as follows;
Spin to Win
After form is created at RMC panel, likewise in-app message, existence of spin to win is controlled by after each customEvent
call. It is shown as follows;
Spin to Win Full | Spin to Win Half |
---|---|
Scratch to Win
After form is created at RMC panel, likewise in-app message, existence of Scratch to Win is controlled by after each customEvent
call. It is shown as follows;
Product Stat Notifier
The Product Stat Notifier action that you define in the RMC Panel works in Product View, Add to Cart and Add/Remove Favorites events. When you send these events, you must make sure that the product id is sent.
Geofencing
To enable location services in your application first of all you need to add the following keys to your Info.plist
file.
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationWhenInUseUsageDescription
An example implementation of these permissions as follows:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We need access to your location for better user experience.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need access to your location for better user experience.</string>
You also need to add the following keys under UIBackgroundModes
in your Info.plist
file to monitor regions, refresh region list and receive push notifications.
<array>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
</array>
When initializing Visilabs SDK you need to set geofenceEnabled
parameter of createAPI
method to true
. You may also change the maxGeofenceCount
to a value lower than 20. Apple prevents any single application from monitoring more than 20 regions simultaneously. Visilabs can use all these slots.
import VisilabsIOS
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Visilabs.createAPI(organizationId: "YOUR_ORGANIZATION_ID", profileId: "YOUR_PROFILE_ID"
, dataSource: "YOUR_DATASOURCE", inAppNotificationsEnabled: false, channel: "IOS"
, requestTimeoutInSeconds: 30, geofenceEnabled: true, maxGeofenceCount: 20)
return true
}
Recommendation
Product recommendations are handled by the recommend
method of SDK. You have to pass 3 mandatory arguments which are zoneId
, productCode
and completion
to recommend
method.
completion
parameter is a closure expression which takes an VisilabsRecommendationResponse
instance as input and returns nothing. The structure of VisilabsRecommendationResponse
is shown below:
public class VisilabsRecommendationResponse {
public var products: [VisilabsProduct]
public var error: VisilabsError?
public var widgetTitle: String = ""
internal init(products: [VisilabsProduct], widgetTitle: String = "", error: VisilabsError? = nil) {
self.products = products
self.widgetTitle = widgetTitle
self.error = error
}
}
VisilabsProduct
class has the following properties:
Property | Type |
---|---|
code | String |
title | String |
img | String |
dest_url | String |
brand | String |
price | Double |
dprice | Double |
cur | String |
dcur | String |
freeshipping | Bool |
samedayshipping | Bool |
rating | Int |
comment | Int |
discount | Double |
attr1 | String |
attr2 | String |
attr3 | String |
attr4 | String |
attr5 | String |
If recommended products exist for given arguments in completion
method you need to handle the array of products.
Visilabs.callAPI().recommend(zoneID: "6", productCode: "pc", filters: []){ response in
if let error = response.error {
print(error)
}else{
print("Recommended Products")
for product in response.products{
print("product code: \(product.code) title: \(product.title)")
}
}
}
You may also pass an array of filters to recommend
method. For example the following implementation returns only the products which contains laptop in the title.
var filters = [VisilabsRecommendationFilter]()
let filter = VisilabsRecommendationFilter(attribute: .PRODUCTNAME, filterType: .like, value: "laptop")
filters.append(filter)
Visilabs.callAPI().recommend(zoneID: "6", productCode: "pc", filters: filters){ response in
if let error = response.error{
print(error)
}else{
print("Widget Title: \(response.widgetTitle)")
print("Recommended Products")
for product in response.products{
print("product code: \(product.code) title: \(product.title)")
}
}
}
Report Recommendation Clicks
To report the clicks of widget recommendations you need to call the trackRecommendationClick
method with the qs
property of Product
object.
Visilabs.callAPI().trackRecommendationClick(qs: product.qs)
Related content
Copyright 2020 Related Digital