Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-10-05 16:13:16 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2e565b695fbec7baa1400f515de14dbc20985023
2e565b69
1 parent
2e6a31b3
add firebase events v2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
378 additions
and
3 deletions
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/ContextualViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/CouponViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/GiftsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/LoyaltyAnalysisViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/TelcoViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
View file @
2e565b6
...
...
@@ -236,7 +236,7 @@ var timer2: DispatchSourceTimer?
if
(
swiftApi
()
.
getTrackingStepsEnabled
()
==
false
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"lo
v
alty_steps_activation"
firebaseEvent
.
_eventName
=
"lo
y
alty_steps_activation"
firebaseEvent
.
_parameters
=
nil
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
...
...
@@ -253,7 +253,103 @@ var timer2: DispatchSourceTimer?
print
(
"**************** WARPLY Webview Log START *****************"
)
print
(
event
)
print
(
"**************** WARPLY Webview Log END *****************"
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_questionnaire_selected"
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_questionnaire_selected"
firebaseEvent
.
setParameter
=
(
"completed"
,
"true"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_questionnaire_answer_again"
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_questionnaire_answer_again"
firebaseEvent
.
_parameters
=
nil
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_questionnaire_answers_deleted"
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_questionnaire_answers_deleted"
firebaseEvent
.
_parameters
=
nil
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_questionnaire_later"
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_questionnaire_later"
firebaseEvent
.
setParameter
=
(
"completed"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_sdk_offer_selected"
)
{
var
name
:
String
=
""
if
(
eventArray
.
count
>
2
)
{
name
=
String
(
eventArray
[
2
])
}
else
{
name
=
""
}
var
type
:
String
=
""
if
(
eventArray
.
count
>
3
)
{
type
=
String
(
eventArray
[
3
])
}
else
{
type
=
""
}
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
name
)
firebaseEvent
.
setParameter
=
(
"type"
,
type
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"loyalty_offer_activated"
)
{
var
name
:
String
=
""
if
(
eventArray
.
count
>
2
)
{
name
=
String
(
eventArray
[
2
])
}
else
{
name
=
""
}
var
type
:
String
=
""
if
(
eventArray
.
count
>
3
)
{
type
=
String
(
eventArray
[
3
])
}
else
{
type
=
""
}
var
successful
:
String
=
""
if
(
eventArray
.
count
>
4
)
{
successful
=
String
(
eventArray
[
4
])
}
else
{
successful
=
""
}
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
name
)
firebaseEvent
.
setParameter
=
(
"type"
,
type
)
firebaseEvent
.
setParameter
=
(
"successful"
,
successful
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
else
if
(
eventArray
[
1
]
==
"time_spent_on_loyalty_sdk"
)
{
var
name
:
String
=
""
if
(
eventArray
.
count
>
2
)
{
name
=
String
(
eventArray
[
2
])
}
else
{
name
=
""
}
var
seconds
:
String
=
""
if
(
eventArray
.
count
>
3
)
{
seconds
=
String
(
eventArray
[
3
])
}
else
{
seconds
=
""
}
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"time_spent_on_loyalty_sdk"
firebaseEvent
.
setParameter
=
(
"name"
,
name
)
firebaseEvent
.
setParameter
=
(
"seconds"
,
seconds
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
}
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/ContextualViewController.swift
View file @
2e565b6
...
...
@@ -156,14 +156,36 @@ import UIKit
if
(
response
!=
nil
)
{
DispatchQueue
.
main
.
async
{
if
(
response
?
.
getStatus
==
1
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"true"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Το αίτημά σου ολοκληρώθηκε επιτυχώς!"
,
"Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου."
)
// self.postEventRequest()
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/CouponViewController.swift
View file @
2e565b6
...
...
@@ -151,6 +151,13 @@ import SwiftEventBus
if
(
response
!=
nil
)
{
DispatchQueue
.
main
.
async
{
if
(
response
?
.
getStatus
==
1
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
couponset
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"true"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showSuccessDialog
(
"Επιτυχής ενεργοποίηση"
,
"Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards."
)
swiftApi
()
.
getCouponsAsync
(
getCouponsCallback
)
...
...
@@ -174,15 +181,46 @@ import SwiftEventBus
}
else
{
}
}
}
else
if
(
response
?
.
getStatus
==
3
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
couponset
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Το κουπόνι δεν είναι διαθέσιμο για αγορά"
)
}
else
if
(
response
?
.
getStatus
==
5
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
couponset
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Δεν έχεις αρκετούς πόντους"
)
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
couponset
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
couponset
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/GiftsViewController.swift
View file @
2e565b6
...
...
@@ -18,6 +18,8 @@ import SwiftEventBus
public
var
ccmsList
:
Array
<
swiftApi
.
LoyaltyContextualOfferModel
>
=
swiftApi
()
.
getCCMSLoyaltyCampaigns
()
public
var
loyaltyList
:
Array
<
swiftApi
.
CampaignItemModel
>
=
swiftApi
()
.
mergeGFYCCMSLoyaltyCampaigns
(
campaigns
:
swiftApi
()
.
getCCMSLoyaltyCampaigns
())
var
timerGFY
:
DispatchSourceTimer
?
var
seconds
:
Int
=
0
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -68,6 +70,14 @@ import SwiftEventBus
super
.
viewWillAppear
(
animated
)
self
.
refreshData
()
self
.
startTimer
()
}
public
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
self
.
stopTimer
()
}
// MARK: - Functions
...
...
@@ -108,6 +118,39 @@ import SwiftEventBus
self
.
tableView
.
reloadData
()
}
func
startTimer
()
{
print
(
"========= GFY Timer Started! ========="
)
let
queue
=
DispatchQueue
(
label
:
Bundle
.
main
.
bundleIdentifier
!
+
".gfy.timer"
)
timerGFY
=
DispatchSource
.
makeTimerSource
(
queue
:
queue
)
timerGFY
!.
schedule
(
deadline
:
.
now
(),
repeating
:
.
seconds
(
1
))
timerGFY
!.
setEventHandler
{
[
weak
self
]
in
// do whatever stuff you want on the background queue here here
print
(
"========= GFY interval! ========="
)
DispatchQueue
.
main
.
async
{
// update your model objects and/or UI here
self
?
.
seconds
=
(
self
?
.
seconds
??
0
)
+
1
}
}
timerGFY
!.
resume
()
}
func
stopTimer
()
{
print
(
"========= GFY Timer Stopped! ========="
)
timerGFY
?
.
cancel
()
timerGFY
=
nil
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"time_spent_on_loyalty_sdk"
firebaseEvent
.
setParameter
=
(
"name"
,
"GiftsForYou"
)
firebaseEvent
.
setParameter
=
(
"seconds"
,
String
(
seconds
))
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
seconds
=
0
}
}
// MARK: - TableView
...
...
@@ -174,6 +217,13 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
if
(
loyaltyCampaignIdExists
==
true
)
{
for
item
in
ccmsCampaigns
{
if
(
item
.
_loyaltyCampaignId
==
campaigns
[
indexPath
.
row
]
.
session_uuid
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
.
_title
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"TelcoViewController"
)
as!
SwiftWarplyFramework
.
TelcoViewController
vc
.
ccms
=
item
...
...
@@ -199,7 +249,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
...
...
@@ -291,6 +341,12 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
seasonalEvent
.
_imageUrl
=
campaigns
[
indexPath
.
row
]
.
_logo_url
??
""
seasonalEvent
.
_loyaltyPackageId
=
campaigns
[
indexPath
.
row
]
.
_loyaltyPackageId
??
""
SwiftEventBus
.
post
(
"seasonal"
,
sender
:
seasonalEvent
)
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
campaigns
[
indexPath
.
row
]
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"seasonal"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
}
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/LoyaltyAnalysisViewController.swift
View file @
2e565b6
...
...
@@ -16,6 +16,9 @@ import UIKit
@IBOutlet
weak
var
contentView
:
UIView
!
var
pageController
:
UIPageViewController
!
var
tabSelected
=
0
var
timerHistory
:
DispatchSourceTimer
?
var
seconds
:
Int
=
0
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -56,6 +59,52 @@ import UIKit
let
analysisVC
=
self
.
viewControllerAt
(
0
)
pageController
.
setViewControllers
([
analysisVC
!
],
direction
:
.
forward
,
animated
:
false
)
}
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
self
.
startTimer
()
}
public
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
self
.
stopTimer
()
}
// MARK: - Functions
func
startTimer
()
{
print
(
"========= GiftsCalculator Timer Started! ========="
)
let
queue
=
DispatchQueue
(
label
:
Bundle
.
main
.
bundleIdentifier
!
+
".history.timer"
)
timerHistory
=
DispatchSource
.
makeTimerSource
(
queue
:
queue
)
timerHistory
!.
schedule
(
deadline
:
.
now
(),
repeating
:
.
seconds
(
1
))
timerHistory
!.
setEventHandler
{
[
weak
self
]
in
// do whatever stuff you want on the background queue here here
print
(
"========= GiftsCalculator interval! ========="
)
DispatchQueue
.
main
.
async
{
// update your model objects and/or UI here
self
?
.
seconds
=
(
self
?
.
seconds
??
0
)
+
1
}
}
timerHistory
!.
resume
()
}
func
stopTimer
()
{
print
(
"========= GiftsCalculator Timer Stopped! ========="
)
timerHistory
?
.
cancel
()
timerHistory
=
nil
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"time_spent_on_loyalty_sdk"
firebaseEvent
.
setParameter
=
(
"name"
,
"GiftsCalculator"
)
firebaseEvent
.
setParameter
=
(
"seconds"
,
String
(
seconds
))
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
seconds
=
0
}
////////////////////////////////////////////////////////////////////////////////
private
func
viewControllerAt
(
_
index
:
Int
)
->
AnalysisChildViewController
?
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
View file @
2e565b6
...
...
@@ -16,6 +16,9 @@ import SwiftEventBus
public
var
campaigns
:
Array
<
swiftApi
.
CampaignItemModel
>
=
[]
public
var
loyaltyList
:
Array
<
swiftApi
.
CampaignItemModel
>
=
swiftApi
()
.
mergeMFYCCMSLoyaltyCampaigns
(
campaigns
:
swiftApi
()
.
getCCMSLoyaltyCampaigns
())
public
var
ccmsList
:
Array
<
swiftApi
.
LoyaltyContextualOfferModel
>
=
swiftApi
()
.
getCCMSLoyaltyCampaigns
()
var
timerMFY
:
DispatchSourceTimer
?
var
seconds
:
Int
=
0
public
override
func
viewDidLoad
()
{
...
...
@@ -56,6 +59,14 @@ import SwiftEventBus
super
.
viewWillAppear
(
animated
)
self
.
refreshData
()
self
.
startTimer
()
}
public
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
self
.
stopTimer
()
}
// MARK: - Functions
...
...
@@ -81,6 +92,39 @@ import SwiftEventBus
self
.
campaigns
=
tempCampaigns
self
.
tableView
.
reloadData
()
}
func
startTimer
()
{
print
(
"========= MFY Timer Started! ========="
)
let
queue
=
DispatchQueue
(
label
:
Bundle
.
main
.
bundleIdentifier
!
+
".mfy.timer"
)
timerMFY
=
DispatchSource
.
makeTimerSource
(
queue
:
queue
)
timerMFY
!.
schedule
(
deadline
:
.
now
(),
repeating
:
.
seconds
(
1
))
timerMFY
!.
setEventHandler
{
[
weak
self
]
in
// do whatever stuff you want on the background queue here here
print
(
"========= MFY interval! ========="
)
DispatchQueue
.
main
.
async
{
// update your model objects and/or UI here
self
?
.
seconds
=
(
self
?
.
seconds
??
0
)
+
1
}
}
timerMFY
!.
resume
()
}
func
stopTimer
()
{
print
(
"========= MFY Timer Stopped! ========="
)
timerMFY
?
.
cancel
()
timerMFY
=
nil
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"time_spent_on_loyalty_sdk"
firebaseEvent
.
setParameter
=
(
"name"
,
"MoreForYou"
)
firebaseEvent
.
setParameter
=
(
"seconds"
,
String
(
seconds
))
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
seconds
=
0
}
}
...
...
@@ -148,6 +192,13 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
if
(
loyaltyCampaignIdExists
==
true
)
{
for
item
in
ccmsCampaigns
{
if
(
item
.
_loyaltyCampaignId
==
campaigns
[
indexPath
.
row
]
.
session_uuid
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
.
_title
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"TelcoViewController"
)
as!
SwiftWarplyFramework
.
TelcoViewController
vc
.
ccms
=
item
...
...
@@ -172,7 +223,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
?
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"name"
,
(
item
.
name
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"coupon"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
...
...
SwiftWarplyFramework/SwiftWarplyFramework/TelcoViewController.swift
View file @
2e565b6
...
...
@@ -210,14 +210,35 @@ import UIKit
if
(
response
!=
nil
)
{
DispatchQueue
.
main
.
async
{
if
(
response
?
.
getStatus
==
1
)
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"true"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Το αίτημά σου ολοκληρώθηκε επιτυχώς!"
,
"Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου."
)
// self.postEventRequest()
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
}
else
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_offer_activated"
firebaseEvent
.
setParameter
=
(
"name"
,
(
self
.
ccms
?
.
_title
??
""
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
firebaseEvent
.
setParameter
=
(
"successful"
,
"false"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
View file @
2e565b6
...
...
@@ -45,6 +45,9 @@ import SwiftEventBus
public
var
dfyCoupons
:
Array
<
swiftApi
.
ActiveDFYCouponModel
>
=
swiftApi
()
.
getActiveDFYCoupons
()
public
var
loyaltyBadge
:
swiftApi
.
LoyaltyBadgeModel
=
swiftApi
()
.
getLoyaltyBadge
()
public
var
profile
:
swiftApi
.
ProfileModel
?
=
swiftApi
()
.
getConsumer
()
var
timerWallet
:
DispatchSourceTimer
?
var
seconds
:
Int
=
0
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -363,6 +366,39 @@ import SwiftEventBus
}))
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
func
startTimer
()
{
print
(
"========= MyRewards Timer Started! ========="
)
let
queue
=
DispatchQueue
(
label
:
Bundle
.
main
.
bundleIdentifier
!
+
".wallet.timer"
)
timerWallet
=
DispatchSource
.
makeTimerSource
(
queue
:
queue
)
timerWallet
!.
schedule
(
deadline
:
.
now
(),
repeating
:
.
seconds
(
1
))
timerWallet
!.
setEventHandler
{
[
weak
self
]
in
// do whatever stuff you want on the background queue here here
print
(
"========= MyRewards interval! ========="
)
DispatchQueue
.
main
.
async
{
// update your model objects and/or UI here
self
?
.
seconds
=
(
self
?
.
seconds
??
0
)
+
1
}
}
timerWallet
!.
resume
()
}
func
stopTimer
()
{
print
(
"========= MyRewards Timer Stopped! ========="
)
timerWallet
?
.
cancel
()
timerWallet
=
nil
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"time_spent_on_loyalty_sdk"
firebaseEvent
.
setParameter
=
(
"name"
,
"MyRewards"
)
firebaseEvent
.
setParameter
=
(
"seconds"
,
String
(
seconds
))
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
seconds
=
0
}
// MARK: - Actions
@IBAction
func
qustionnaireButtonAction
(
_
sender
:
Any
)
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
2e565b6
...
...
@@ -5025,6 +5025,12 @@ public class swiftApi {
}
else
if
(
isTelco
&&
(
loyaltyCampaign
.
session_uuid
==
ccms
.
_loyaltyCampaignId
))
{
let
firebaseEvent
=
swiftApi
.
LoyaltySDKFirebaseEventModel
()
firebaseEvent
.
_eventName
=
"loyalty_sdk_offer_selected"
firebaseEvent
.
setParameter
=
(
"name"
,
(
ccms
.
_title
))
firebaseEvent
.
setParameter
=
(
"type"
,
"gift"
)
SwiftEventBus
.
post
(
"firebase"
,
sender
:
firebaseEvent
)
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"TelcoViewController"
)
as!
SwiftWarplyFramework
.
TelcoViewController
vc
.
ccms
=
ccms
...
...
Please
register
or
login
to post a comment