Mobile Carousel iOS
Configuration on Mobile Data Campaign
Name | Detail | Example |
---|---|---|
RecItemTitle | Title | Recommend Items |
RecItemTitleAlign | Title Align | center (pick either left or center or right) |
RecItemTitleFontColor | Title Color | #333333 (HEX, RGBA ,etc) |
RecItemTitleFontSize | Title Font Size | 30px |
RecItems | Recommend Items | ${items} |
※ Set these properties of Mobile Data Campaign
Installation Step
- Set Mobile Data Campaign with the documentation
- Open the file downloaded on the top page
- Place
carousel.html
frommobile
>popup
>ios
to the local directory - Set webview in Storyboard
- Add Outlet in ViewController file as
@IBOutlet weak var webView: WKWebView!
- Addthe code below in ViewController file
func handleCarouselCampaign(campaign: EVGCampaign) {
// Carousel
/// Data to use for Carousel
var itemData: [Codable] = []
/// Carousel Title
let recCampaignSubItem = CampaignItem(
titleText: campaign.data["RecItemTitle"] as! String,
titleSize: campaign.data["RecItemTitleFontSize"] as! String,
titleColor: campaign.data["RecItemTitleFontColor"] as! String,
titleAlign: campaign.data["RecItemTitleAlign"] as! String
)
let campObject = encodeJson(campData: recCampaignSubItem)
itemData.append( campObject )
/// Carousel Content
let recitems: Array = campaign.data["RecItems"] as! Array<[String: Any]>
for recitem: [String: Any] in recitems {
let recommendItem = RecommendItem(
id: recitem["_id"] as! String,
name: recitem["name"] as! String,
imageUrl: recitem["imageUrl"] as! String,
price: "\(recitem["price"]!)"
)
let jsonObject = encodeJson(campData: recommendItem)
itemData.append( jsonObject )
}
carouselView = CarouselController(
webView: webView!,
webViewFile: "carousel",
campData: itemData
)
// / Carousel
evergageScreen?.trackImpression(campaign)
// Only display the campaign if the user is not in the control group.
if (!campaign.isControlGroup) {
NSLog("New active campaign name %@ for target %@ with data %@",
campaign.campaignName, campaign.target, campaign.data)
}
}