Showing
9 changed files
with
378 additions
and
3 deletions
... | @@ -236,7 +236,7 @@ var timer2: DispatchSourceTimer? | ... | @@ -236,7 +236,7 @@ var timer2: DispatchSourceTimer? |
236 | 236 | ||
237 | if (swiftApi().getTrackingStepsEnabled() == false) { | 237 | if (swiftApi().getTrackingStepsEnabled() == false) { |
238 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | 238 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() |
239 | - firebaseEvent._eventName = "lovalty_steps_activation" | 239 | + firebaseEvent._eventName = "loyalty_steps_activation" |
240 | firebaseEvent._parameters = nil | 240 | firebaseEvent._parameters = nil |
241 | SwiftEventBus.post("firebase", sender: firebaseEvent) | 241 | SwiftEventBus.post("firebase", sender: firebaseEvent) |
242 | 242 | ||
... | @@ -253,7 +253,103 @@ var timer2: DispatchSourceTimer? | ... | @@ -253,7 +253,103 @@ var timer2: DispatchSourceTimer? |
253 | print("**************** WARPLY Webview Log START *****************") | 253 | print("**************** WARPLY Webview Log START *****************") |
254 | print(event) | 254 | print(event) |
255 | print("**************** WARPLY Webview Log END *****************") | 255 | print("**************** WARPLY Webview Log END *****************") |
256 | + | ||
257 | + } else if (eventArray[1] == "loyalty_questionnaire_selected") { | ||
258 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
259 | + firebaseEvent._eventName = "loyalty_questionnaire_selected" | ||
260 | + firebaseEvent.setParameter = ("completed", "true") | ||
261 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
262 | + | ||
263 | + } else if (eventArray[1] == "loyalty_questionnaire_answer_again") { | ||
264 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
265 | + firebaseEvent._eventName = "loyalty_questionnaire_answer_again" | ||
266 | + firebaseEvent._parameters = nil | ||
267 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
268 | + | ||
269 | + } else if (eventArray[1] == "loyalty_questionnaire_answers_deleted") { | ||
270 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
271 | + firebaseEvent._eventName = "loyalty_questionnaire_answers_deleted" | ||
272 | + firebaseEvent._parameters = nil | ||
273 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
274 | + | ||
275 | + } else if (eventArray[1] == "loyalty_questionnaire_later") { | ||
276 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
277 | + firebaseEvent._eventName = "loyalty_questionnaire_later" | ||
278 | + firebaseEvent.setParameter = ("completed", "false") | ||
279 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
280 | + | ||
281 | + } else if (eventArray[1] == "loyalty_sdk_offer_selected") { | ||
282 | + var name: String = "" | ||
283 | + if (eventArray.count > 2) { | ||
284 | + name = String(eventArray[2]) | ||
285 | + } else { | ||
286 | + name = "" | ||
287 | + } | ||
288 | + | ||
289 | + var type: String = "" | ||
290 | + if (eventArray.count > 3) { | ||
291 | + type = String(eventArray[3]) | ||
292 | + } else { | ||
293 | + type = "" | ||
294 | + } | ||
295 | + | ||
296 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
297 | + firebaseEvent._eventName = "loyalty_sdk_offer_selected" | ||
298 | + firebaseEvent.setParameter = ("name", name) | ||
299 | + firebaseEvent.setParameter = ("type", type) | ||
300 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
301 | + | ||
302 | + } else if (eventArray[1] == "loyalty_offer_activated") { | ||
303 | + var name: String = "" | ||
304 | + if (eventArray.count > 2) { | ||
305 | + name = String(eventArray[2]) | ||
306 | + } else { | ||
307 | + name = "" | ||
308 | + } | ||
309 | + | ||
310 | + var type: String = "" | ||
311 | + if (eventArray.count > 3) { | ||
312 | + type = String(eventArray[3]) | ||
313 | + } else { | ||
314 | + type = "" | ||
315 | + } | ||
316 | + | ||
317 | + var successful: String = "" | ||
318 | + if (eventArray.count > 4) { | ||
319 | + successful = String(eventArray[4]) | ||
320 | + } else { | ||
321 | + successful = "" | ||
322 | + } | ||
323 | + | ||
324 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
325 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
326 | + firebaseEvent.setParameter = ("name", name) | ||
327 | + firebaseEvent.setParameter = ("type", type) | ||
328 | + firebaseEvent.setParameter = ("successful", successful) | ||
329 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
330 | + | ||
331 | + } else if (eventArray[1] == "time_spent_on_loyalty_sdk") { | ||
332 | + var name: String = "" | ||
333 | + if (eventArray.count > 2) { | ||
334 | + name = String(eventArray[2]) | ||
335 | + } else { | ||
336 | + name = "" | ||
337 | + } | ||
338 | + | ||
339 | + var seconds: String = "" | ||
340 | + if (eventArray.count > 3) { | ||
341 | + seconds = String(eventArray[3]) | ||
342 | + } else { | ||
343 | + seconds = "" | ||
344 | + } | ||
345 | + | ||
346 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
347 | + firebaseEvent._eventName = "time_spent_on_loyalty_sdk" | ||
348 | + firebaseEvent.setParameter = ("name", name) | ||
349 | + firebaseEvent.setParameter = ("seconds", seconds) | ||
350 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
256 | } | 351 | } |
352 | + | ||
257 | } | 353 | } |
258 | } | 354 | } |
259 | } | 355 | } | ... | ... |
... | @@ -156,14 +156,36 @@ import UIKit | ... | @@ -156,14 +156,36 @@ import UIKit |
156 | if (response != nil) { | 156 | if (response != nil) { |
157 | DispatchQueue.main.async { | 157 | DispatchQueue.main.async { |
158 | if (response?.getStatus == 1) { | 158 | if (response?.getStatus == 1) { |
159 | + | ||
160 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
161 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
162 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
163 | + firebaseEvent.setParameter = ("type", "gift") | ||
164 | + firebaseEvent.setParameter = ("successful", "true") | ||
165 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
166 | + | ||
159 | self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") | 167 | self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") |
160 | // self.postEventRequest() | 168 | // self.postEventRequest() |
161 | 169 | ||
162 | } else { | 170 | } else { |
171 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
172 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
173 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
174 | + firebaseEvent.setParameter = ("type", "gift") | ||
175 | + firebaseEvent.setParameter = ("successful", "false") | ||
176 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
177 | + | ||
163 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 178 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
164 | } | 179 | } |
165 | } | 180 | } |
166 | } else { | 181 | } else { |
182 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
183 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
184 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
185 | + firebaseEvent.setParameter = ("type", "gift") | ||
186 | + firebaseEvent.setParameter = ("successful", "false") | ||
187 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
188 | + | ||
167 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 189 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
168 | } | 190 | } |
169 | } | 191 | } | ... | ... |
... | @@ -151,6 +151,13 @@ import SwiftEventBus | ... | @@ -151,6 +151,13 @@ import SwiftEventBus |
151 | if (response != nil) { | 151 | if (response != nil) { |
152 | DispatchQueue.main.async { | 152 | DispatchQueue.main.async { |
153 | if (response?.getStatus == 1) { | 153 | if (response?.getStatus == 1) { |
154 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
155 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
156 | + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? "")) | ||
157 | + firebaseEvent.setParameter = ("type", "coupon") | ||
158 | + firebaseEvent.setParameter = ("successful", "true") | ||
159 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
160 | + | ||
154 | self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.") | 161 | self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.") |
155 | 162 | ||
156 | swiftApi().getCouponsAsync(getCouponsCallback) | 163 | swiftApi().getCouponsAsync(getCouponsCallback) |
... | @@ -174,15 +181,46 @@ import SwiftEventBus | ... | @@ -174,15 +181,46 @@ import SwiftEventBus |
174 | } else { | 181 | } else { |
175 | } | 182 | } |
176 | } | 183 | } |
184 | + | ||
177 | } else if (response?.getStatus == 3) { | 185 | } else if (response?.getStatus == 3) { |
186 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
187 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
188 | + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? "")) | ||
189 | + firebaseEvent.setParameter = ("type", "coupon") | ||
190 | + firebaseEvent.setParameter = ("successful", "false") | ||
191 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
192 | + | ||
178 | self.showDialog("Αποτυχία","Το κουπόνι δεν είναι διαθέσιμο για αγορά") | 193 | self.showDialog("Αποτυχία","Το κουπόνι δεν είναι διαθέσιμο για αγορά") |
194 | + | ||
179 | } else if (response?.getStatus == 5) { | 195 | } else if (response?.getStatus == 5) { |
196 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
197 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
198 | + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? "")) | ||
199 | + firebaseEvent.setParameter = ("type", "coupon") | ||
200 | + firebaseEvent.setParameter = ("successful", "false") | ||
201 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
202 | + | ||
180 | self.showDialog("Αποτυχία","Δεν έχεις αρκετούς πόντους") | 203 | self.showDialog("Αποτυχία","Δεν έχεις αρκετούς πόντους") |
204 | + | ||
181 | } else { | 205 | } else { |
206 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
207 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
208 | + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? "")) | ||
209 | + firebaseEvent.setParameter = ("type", "coupon") | ||
210 | + firebaseEvent.setParameter = ("successful", "false") | ||
211 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
212 | + | ||
182 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 213 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
183 | } | 214 | } |
184 | } | 215 | } |
185 | } else { | 216 | } else { |
217 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
218 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
219 | + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? "")) | ||
220 | + firebaseEvent.setParameter = ("type", "coupon") | ||
221 | + firebaseEvent.setParameter = ("successful", "false") | ||
222 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
223 | + | ||
186 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 224 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
187 | } | 225 | } |
188 | } | 226 | } | ... | ... |
... | @@ -18,6 +18,8 @@ import SwiftEventBus | ... | @@ -18,6 +18,8 @@ import SwiftEventBus |
18 | public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns() | 18 | public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns() |
19 | public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) | 19 | public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) |
20 | 20 | ||
21 | + var timerGFY: DispatchSourceTimer? | ||
22 | + var seconds: Int = 0 | ||
21 | 23 | ||
22 | public override func viewDidLoad() { | 24 | public override func viewDidLoad() { |
23 | super.viewDidLoad() | 25 | super.viewDidLoad() |
... | @@ -68,6 +70,14 @@ import SwiftEventBus | ... | @@ -68,6 +70,14 @@ import SwiftEventBus |
68 | super.viewWillAppear(animated) | 70 | super.viewWillAppear(animated) |
69 | 71 | ||
70 | self.refreshData() | 72 | self.refreshData() |
73 | + | ||
74 | + self.startTimer() | ||
75 | + } | ||
76 | + | ||
77 | + public override func viewWillDisappear(_ animated: Bool) { | ||
78 | + super.viewWillDisappear(animated) | ||
79 | + | ||
80 | + self.stopTimer() | ||
71 | } | 81 | } |
72 | 82 | ||
73 | // MARK: - Functions | 83 | // MARK: - Functions |
... | @@ -108,6 +118,39 @@ import SwiftEventBus | ... | @@ -108,6 +118,39 @@ import SwiftEventBus |
108 | self.tableView.reloadData() | 118 | self.tableView.reloadData() |
109 | } | 119 | } |
110 | 120 | ||
121 | + func startTimer() { | ||
122 | + print("========= GFY Timer Started! =========") | ||
123 | + | ||
124 | + let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".gfy.timer") | ||
125 | + timerGFY = DispatchSource.makeTimerSource(queue: queue) | ||
126 | + timerGFY!.schedule(deadline: .now(), repeating: .seconds(1)) | ||
127 | + timerGFY!.setEventHandler { [weak self] in | ||
128 | + // do whatever stuff you want on the background queue here here | ||
129 | + print("========= GFY interval! =========") | ||
130 | + | ||
131 | + DispatchQueue.main.async { | ||
132 | + // update your model objects and/or UI here | ||
133 | + self?.seconds = (self?.seconds ?? 0) + 1 | ||
134 | + | ||
135 | + } | ||
136 | + } | ||
137 | + timerGFY!.resume() | ||
138 | + } | ||
139 | + | ||
140 | + func stopTimer() { | ||
141 | + print("========= GFY Timer Stopped! =========") | ||
142 | + timerGFY?.cancel() | ||
143 | + timerGFY = nil | ||
144 | + | ||
145 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
146 | + firebaseEvent._eventName = "time_spent_on_loyalty_sdk" | ||
147 | + firebaseEvent.setParameter = ("name", "GiftsForYou") | ||
148 | + firebaseEvent.setParameter = ("seconds", String(seconds)) | ||
149 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
150 | + | ||
151 | + seconds = 0 | ||
152 | + } | ||
153 | + | ||
111 | } | 154 | } |
112 | 155 | ||
113 | // MARK: - TableView | 156 | // MARK: - TableView |
... | @@ -174,6 +217,13 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -174,6 +217,13 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
174 | if (loyaltyCampaignIdExists == true) { | 217 | if (loyaltyCampaignIdExists == true) { |
175 | for item in ccmsCampaigns { | 218 | for item in ccmsCampaigns { |
176 | if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { | 219 | if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { |
220 | + | ||
221 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
222 | + firebaseEvent._eventName = "loyalty_sdk_offer_selected" | ||
223 | + firebaseEvent.setParameter = ("name", (item._title)) | ||
224 | + firebaseEvent.setParameter = ("type", "gift") | ||
225 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
226 | + | ||
177 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 227 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
178 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController | 228 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController |
179 | vc.ccms = item | 229 | vc.ccms = item |
... | @@ -199,7 +249,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -199,7 +249,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
199 | 249 | ||
200 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | 250 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() |
201 | firebaseEvent._eventName = "loyalty_sdk_offer_selected" | 251 | firebaseEvent._eventName = "loyalty_sdk_offer_selected" |
202 | - firebaseEvent.setParameter = ("name", (item?.name ?? "")) | 252 | + firebaseEvent.setParameter = ("name", (item.name ?? "")) |
203 | firebaseEvent.setParameter = ("type", "coupon") | 253 | firebaseEvent.setParameter = ("type", "coupon") |
204 | SwiftEventBus.post("firebase", sender: firebaseEvent) | 254 | SwiftEventBus.post("firebase", sender: firebaseEvent) |
205 | 255 | ||
... | @@ -291,6 +341,12 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -291,6 +341,12 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
291 | seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? "" | 341 | seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? "" |
292 | seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? "" | 342 | seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? "" |
293 | SwiftEventBus.post("seasonal", sender: seasonalEvent) | 343 | SwiftEventBus.post("seasonal", sender: seasonalEvent) |
344 | + | ||
345 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
346 | + firebaseEvent._eventName = "loyalty_sdk_offer_selected" | ||
347 | + firebaseEvent.setParameter = ("name", (campaigns[indexPath.row]._title ?? "")) | ||
348 | + firebaseEvent.setParameter = ("type", "seasonal") | ||
349 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
294 | } | 350 | } |
295 | } | 351 | } |
296 | } | 352 | } | ... | ... |
... | @@ -16,6 +16,9 @@ import UIKit | ... | @@ -16,6 +16,9 @@ import UIKit |
16 | @IBOutlet weak var contentView: UIView! | 16 | @IBOutlet weak var contentView: UIView! |
17 | var pageController: UIPageViewController! | 17 | var pageController: UIPageViewController! |
18 | var tabSelected = 0 | 18 | var tabSelected = 0 |
19 | + | ||
20 | + var timerHistory: DispatchSourceTimer? | ||
21 | + var seconds: Int = 0 | ||
19 | 22 | ||
20 | public override func viewDidLoad() { | 23 | public override func viewDidLoad() { |
21 | super.viewDidLoad() | 24 | super.viewDidLoad() |
... | @@ -56,6 +59,52 @@ import UIKit | ... | @@ -56,6 +59,52 @@ import UIKit |
56 | let analysisVC = self.viewControllerAt(0) | 59 | let analysisVC = self.viewControllerAt(0) |
57 | pageController.setViewControllers([analysisVC!], direction:.forward, animated:false) | 60 | pageController.setViewControllers([analysisVC!], direction:.forward, animated:false) |
58 | } | 61 | } |
62 | + | ||
63 | + public override func viewWillAppear(_ animated: Bool) { | ||
64 | + super.viewWillAppear(animated) | ||
65 | + | ||
66 | + self.startTimer() | ||
67 | + } | ||
68 | + | ||
69 | + public override func viewWillDisappear(_ animated: Bool) { | ||
70 | + super.viewWillDisappear(animated) | ||
71 | + | ||
72 | + self.stopTimer() | ||
73 | + } | ||
74 | + | ||
75 | + // MARK: - Functions | ||
76 | + func startTimer() { | ||
77 | + print("========= GiftsCalculator Timer Started! =========") | ||
78 | + | ||
79 | + let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer") | ||
80 | + timerHistory = DispatchSource.makeTimerSource(queue: queue) | ||
81 | + timerHistory!.schedule(deadline: .now(), repeating: .seconds(1)) | ||
82 | + timerHistory!.setEventHandler { [weak self] in | ||
83 | + // do whatever stuff you want on the background queue here here | ||
84 | + print("========= GiftsCalculator interval! =========") | ||
85 | + | ||
86 | + DispatchQueue.main.async { | ||
87 | + // update your model objects and/or UI here | ||
88 | + self?.seconds = (self?.seconds ?? 0) + 1 | ||
89 | + | ||
90 | + } | ||
91 | + } | ||
92 | + timerHistory!.resume() | ||
93 | + } | ||
94 | + | ||
95 | + func stopTimer() { | ||
96 | + print("========= GiftsCalculator Timer Stopped! =========") | ||
97 | + timerHistory?.cancel() | ||
98 | + timerHistory = nil | ||
99 | + | ||
100 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
101 | + firebaseEvent._eventName = "time_spent_on_loyalty_sdk" | ||
102 | + firebaseEvent.setParameter = ("name", "GiftsCalculator") | ||
103 | + firebaseEvent.setParameter = ("seconds", String(seconds)) | ||
104 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
105 | + | ||
106 | + seconds = 0 | ||
107 | + } | ||
59 | 108 | ||
60 | //////////////////////////////////////////////////////////////////////////////// | 109 | //////////////////////////////////////////////////////////////////////////////// |
61 | private func viewControllerAt(_ index:Int) -> AnalysisChildViewController? | 110 | private func viewControllerAt(_ index:Int) -> AnalysisChildViewController? | ... | ... |
... | @@ -16,6 +16,9 @@ import SwiftEventBus | ... | @@ -16,6 +16,9 @@ import SwiftEventBus |
16 | public var campaigns:Array<swiftApi.CampaignItemModel> = [] | 16 | public var campaigns:Array<swiftApi.CampaignItemModel> = [] |
17 | public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) | 17 | public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) |
18 | public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns() | 18 | public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns() |
19 | + | ||
20 | + var timerMFY: DispatchSourceTimer? | ||
21 | + var seconds: Int = 0 | ||
19 | 22 | ||
20 | 23 | ||
21 | public override func viewDidLoad() { | 24 | public override func viewDidLoad() { |
... | @@ -56,6 +59,14 @@ import SwiftEventBus | ... | @@ -56,6 +59,14 @@ import SwiftEventBus |
56 | super.viewWillAppear(animated) | 59 | super.viewWillAppear(animated) |
57 | 60 | ||
58 | self.refreshData() | 61 | self.refreshData() |
62 | + | ||
63 | + self.startTimer() | ||
64 | + } | ||
65 | + | ||
66 | + public override func viewWillDisappear(_ animated: Bool) { | ||
67 | + super.viewWillDisappear(animated) | ||
68 | + | ||
69 | + self.stopTimer() | ||
59 | } | 70 | } |
60 | 71 | ||
61 | // MARK: - Functions | 72 | // MARK: - Functions |
... | @@ -81,6 +92,39 @@ import SwiftEventBus | ... | @@ -81,6 +92,39 @@ import SwiftEventBus |
81 | self.campaigns = tempCampaigns | 92 | self.campaigns = tempCampaigns |
82 | self.tableView.reloadData() | 93 | self.tableView.reloadData() |
83 | } | 94 | } |
95 | + | ||
96 | + func startTimer() { | ||
97 | + print("========= MFY Timer Started! =========") | ||
98 | + | ||
99 | + let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".mfy.timer") | ||
100 | + timerMFY = DispatchSource.makeTimerSource(queue: queue) | ||
101 | + timerMFY!.schedule(deadline: .now(), repeating: .seconds(1)) | ||
102 | + timerMFY!.setEventHandler { [weak self] in | ||
103 | + // do whatever stuff you want on the background queue here here | ||
104 | + print("========= MFY interval! =========") | ||
105 | + | ||
106 | + DispatchQueue.main.async { | ||
107 | + // update your model objects and/or UI here | ||
108 | + self?.seconds = (self?.seconds ?? 0) + 1 | ||
109 | + | ||
110 | + } | ||
111 | + } | ||
112 | + timerMFY!.resume() | ||
113 | + } | ||
114 | + | ||
115 | + func stopTimer() { | ||
116 | + print("========= MFY Timer Stopped! =========") | ||
117 | + timerMFY?.cancel() | ||
118 | + timerMFY = nil | ||
119 | + | ||
120 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
121 | + firebaseEvent._eventName = "time_spent_on_loyalty_sdk" | ||
122 | + firebaseEvent.setParameter = ("name", "MoreForYou") | ||
123 | + firebaseEvent.setParameter = ("seconds", String(seconds)) | ||
124 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
125 | + | ||
126 | + seconds = 0 | ||
127 | + } | ||
84 | 128 | ||
85 | } | 129 | } |
86 | 130 | ||
... | @@ -148,6 +192,13 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -148,6 +192,13 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
148 | if (loyaltyCampaignIdExists == true) { | 192 | if (loyaltyCampaignIdExists == true) { |
149 | for item in ccmsCampaigns { | 193 | for item in ccmsCampaigns { |
150 | if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { | 194 | if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { |
195 | + | ||
196 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
197 | + firebaseEvent._eventName = "loyalty_sdk_offer_selected" | ||
198 | + firebaseEvent.setParameter = ("name", (item._title)) | ||
199 | + firebaseEvent.setParameter = ("type", "gift") | ||
200 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
201 | + | ||
151 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 202 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
152 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController | 203 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController |
153 | vc.ccms = item | 204 | vc.ccms = item |
... | @@ -172,7 +223,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -172,7 +223,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
172 | 223 | ||
173 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | 224 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() |
174 | firebaseEvent._eventName = "loyalty_sdk_offer_selected" | 225 | firebaseEvent._eventName = "loyalty_sdk_offer_selected" |
175 | - firebaseEvent.setParameter = ("name", (item?.name ?? "")) | 226 | + firebaseEvent.setParameter = ("name", (item.name ?? "")) |
176 | firebaseEvent.setParameter = ("type", "coupon") | 227 | firebaseEvent.setParameter = ("type", "coupon") |
177 | SwiftEventBus.post("firebase", sender: firebaseEvent) | 228 | SwiftEventBus.post("firebase", sender: firebaseEvent) |
178 | 229 | ... | ... |
... | @@ -210,14 +210,35 @@ import UIKit | ... | @@ -210,14 +210,35 @@ import UIKit |
210 | if (response != nil) { | 210 | if (response != nil) { |
211 | DispatchQueue.main.async { | 211 | DispatchQueue.main.async { |
212 | if (response?.getStatus == 1) { | 212 | if (response?.getStatus == 1) { |
213 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
214 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
215 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
216 | + firebaseEvent.setParameter = ("type", "gift") | ||
217 | + firebaseEvent.setParameter = ("successful", "true") | ||
218 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
219 | + | ||
213 | self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") | 220 | self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") |
214 | // self.postEventRequest() | 221 | // self.postEventRequest() |
215 | 222 | ||
216 | } else { | 223 | } else { |
224 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
225 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
226 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
227 | + firebaseEvent.setParameter = ("type", "gift") | ||
228 | + firebaseEvent.setParameter = ("successful", "false") | ||
229 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
230 | + | ||
217 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 231 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
218 | } | 232 | } |
219 | } | 233 | } |
220 | } else { | 234 | } else { |
235 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
236 | + firebaseEvent._eventName = "loyalty_offer_activated" | ||
237 | + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) | ||
238 | + firebaseEvent.setParameter = ("type", "gift") | ||
239 | + firebaseEvent.setParameter = ("successful", "false") | ||
240 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
241 | + | ||
221 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | 242 | self.showDialog("Αποτυχία","Κάτι πήγε στραβά") |
222 | } | 243 | } |
223 | } | 244 | } | ... | ... |
... | @@ -45,6 +45,9 @@ import SwiftEventBus | ... | @@ -45,6 +45,9 @@ import SwiftEventBus |
45 | public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() | 45 | public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() |
46 | public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() | 46 | public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() |
47 | public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer() | 47 | public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer() |
48 | + | ||
49 | + var timerWallet: DispatchSourceTimer? | ||
50 | + var seconds: Int = 0 | ||
48 | 51 | ||
49 | public override func viewDidLoad() { | 52 | public override func viewDidLoad() { |
50 | super.viewDidLoad() | 53 | super.viewDidLoad() |
... | @@ -363,6 +366,39 @@ import SwiftEventBus | ... | @@ -363,6 +366,39 @@ import SwiftEventBus |
363 | })) | 366 | })) |
364 | self.present(alert, animated: true, completion: nil) | 367 | self.present(alert, animated: true, completion: nil) |
365 | } | 368 | } |
369 | + | ||
370 | + func startTimer() { | ||
371 | + print("========= MyRewards Timer Started! =========") | ||
372 | + | ||
373 | + let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".wallet.timer") | ||
374 | + timerWallet = DispatchSource.makeTimerSource(queue: queue) | ||
375 | + timerWallet!.schedule(deadline: .now(), repeating: .seconds(1)) | ||
376 | + timerWallet!.setEventHandler { [weak self] in | ||
377 | + // do whatever stuff you want on the background queue here here | ||
378 | + print("========= MyRewards interval! =========") | ||
379 | + | ||
380 | + DispatchQueue.main.async { | ||
381 | + // update your model objects and/or UI here | ||
382 | + self?.seconds = (self?.seconds ?? 0) + 1 | ||
383 | + | ||
384 | + } | ||
385 | + } | ||
386 | + timerWallet!.resume() | ||
387 | + } | ||
388 | + | ||
389 | + func stopTimer() { | ||
390 | + print("========= MyRewards Timer Stopped! =========") | ||
391 | + timerWallet?.cancel() | ||
392 | + timerWallet = nil | ||
393 | + | ||
394 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
395 | + firebaseEvent._eventName = "time_spent_on_loyalty_sdk" | ||
396 | + firebaseEvent.setParameter = ("name", "MyRewards") | ||
397 | + firebaseEvent.setParameter = ("seconds", String(seconds)) | ||
398 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
399 | + | ||
400 | + seconds = 0 | ||
401 | + } | ||
366 | 402 | ||
367 | // MARK: - Actions | 403 | // MARK: - Actions |
368 | @IBAction func qustionnaireButtonAction(_ sender: Any) { | 404 | @IBAction func qustionnaireButtonAction(_ sender: Any) { | ... | ... |
... | @@ -5025,6 +5025,12 @@ public class swiftApi { | ... | @@ -5025,6 +5025,12 @@ public class swiftApi { |
5025 | 5025 | ||
5026 | } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { | 5026 | } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { |
5027 | 5027 | ||
5028 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
5029 | + firebaseEvent._eventName = "loyalty_sdk_offer_selected" | ||
5030 | + firebaseEvent.setParameter = ("name", (ccms._title)) | ||
5031 | + firebaseEvent.setParameter = ("type", "gift") | ||
5032 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
5033 | + | ||
5028 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 5034 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
5029 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController | 5035 | let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController |
5030 | vc.ccms = ccms | 5036 | vc.ccms = ccms | ... | ... |
-
Please register or login to post a comment