Manos Chorianopoulos

Add webview Location Permissions

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -10,15 +10,73 @@ import UIKit
import WebKit
import SwiftEventBus
// Location Permissions
import CoreLocation
var timer2: DispatchSourceTimer?
@objc public class CampaignViewController: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
//@objc public class CampaignViewController: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
@objc public class CampaignViewController: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, CLLocationManagerDelegate, WKUIDelegate, UIScrollViewDelegate {
@IBOutlet weak var webview: WKWebView!
public var campaignUrl: String = ""
public var params: String = ""
public var showHeader: Bool = false
// Location Permissions
var webView: WKWebView!
var locationManager: CLLocationManager!
var listenersCount = 0;
public override func loadView() {
super.loadView();
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
let contentController = WKUserContentController()
contentController.add(self, name: "Cosmote")
contentController.add(self, name: "listenerAdded");
contentController.add(self, name: "listenerRemoved");
let config = WKWebViewConfiguration()
config.userContentController = contentController
let script = WKUserScript(source: getJavaScripToEvaluate(), injectionTime: .atDocumentEnd, forMainFrameOnly: true)
contentController.addUserScript(script)
self.webView = WKWebView(frame: self.view.bounds, configuration: config)
webView?.uiDelegate = self
webView?.navigationDelegate = self
webView?.scrollView.delegate = self
webView?.scrollView.bounces = false
webView?.scrollView.bouncesZoom = false
view.addSubview(webView!)
}
public override func viewDidLoad() {
super.viewDidLoad()
let campaignUrl = campaignUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
print("Webview url: " + (campaignUrl ?? ""))
if let url = URL(string: campaignUrl ?? "") {
webView.load(URLRequest(url: url))
webView.allowsBackForwardNavigationGestures = true
}
self.hidesBottomBarWhenPushed = true
if (showHeader) {
setBackButton()
}
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if (!showHeader) {
......@@ -61,26 +119,27 @@ var timer2: DispatchSourceTimer?
}
}
public override func viewDidLoad() {
super.viewDidLoad()
var campaignUrl = campaignUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
print("Webview url: " + (campaignUrl ?? ""))
self.hidesBottomBarWhenPushed = true
if (showHeader) {
setBackButton()
}
webview.navigationDelegate = self
if let url = URL(string: campaignUrl ?? "") {
webview.load(URLRequest(url: url))
webview.allowsBackForwardNavigationGestures = true
}
webview.configuration.userContentController.add(self, name: "Cosmote")
}
// public override func viewDidLoad() {
// super.viewDidLoad()
//
// var campaignUrl = campaignUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
// print("Webview url: " + (campaignUrl ?? ""))
//
// self.hidesBottomBarWhenPushed = true
//
// if (showHeader) {
// setBackButton()
// }
//
// webview.navigationDelegate = self
//
// if let url = URL(string: campaignUrl ?? "") {
// webview.load(URLRequest(url: url))
// webview.allowsBackForwardNavigationGestures = true
// }
//
// webview.configuration.userContentController.add(self, name: "Cosmote")
// }
// MARK: - Functions
func startTimer() {
......@@ -121,6 +180,149 @@ var timer2: DispatchSourceTimer?
timer2?.cancel()
timer2 = nil
}
// Location Permissions
func locationServicesIsEnabled() -> Bool {
return (CLLocationManager.locationServicesEnabled()) ? true : false;
}
func authorizationStatusNeedRequest(status: CLAuthorizationStatus) -> Bool {
return (status == .notDetermined) ? true : false;
}
func authorizationStatusIsGranted(status: CLAuthorizationStatus) -> Bool {
return (status == .authorizedAlways || status == .authorizedWhenInUse) ? true : false;
}
func authorizationStatusIsDenied(status: CLAuthorizationStatus) -> Bool {
return (status == .restricted || status == .denied) ? true : false;
}
func onLocationServicesIsDisabled() {
// webView.evaluateJavaScript("navigator.geolocation.helper.error(2, 'Location services disabled');");
locationManager.requestWhenInUseAuthorization();
}
func onAuthorizationStatusNeedRequest() {
locationManager.requestWhenInUseAuthorization();
}
func onAuthorizationStatusIsGranted() {
locationManager.startUpdatingLocation();
}
func onAuthorizationStatusIsDenied() {
webView.evaluateJavaScript("navigator.geolocation.helper.error(1, 'App does not have location permission');");
}
public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print("=== locationManager didChangeAuthorization: ",status)
// didChangeAuthorization is also called at app startup, so this condition checks listeners
// count before doing anything otherwise app will start location service without reason
if (listenersCount > 0) {
if (authorizationStatusIsDenied(status: status)) {
onAuthorizationStatusIsDenied();
}
else if (authorizationStatusIsGranted(status: status)) {
onAuthorizationStatusIsGranted();
}
}
}
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.last {
print("=== locationManager didUpdateLocations latitude: ",location.coordinate.latitude)
print("=== locationManager didUpdateLocations longitude: ",location.coordinate.longitude)
webView.evaluateJavaScript("navigator.geolocation.helper.success('\(location.timestamp)', \(location.coordinate.latitude), \(location.coordinate.longitude), \(location.altitude), \(location.horizontalAccuracy), \(location.verticalAccuracy), \(location.course), \(location.speed));");
}
}
public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("=== locationManager didFailWithError: ", error)
webView.evaluateJavaScript("navigator.geolocation.helper.error(2, 'Failed to get position (\(error.localizedDescription))');");
}
func getJavaScripToEvaluate() -> String {
let javaScripToEvaluate = """
// management for success and error listeners and its calling
navigator.geolocation.helper = {
listeners: {},
noop: function() {},
id: function() {
var min = 1, max = 1000;
return Math.floor(Math.random() * (max - min + 1)) + min;
},
clear: function(isError) {
for (var id in this.listeners) {
if (isError || this.listeners[id].onetime) {
navigator.geolocation.clearWatch(id);
}
}
},
success: function(timestamp, latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed) {
var position = {
timestamp: new Date(timestamp).getTime() || new Date().getTime(), // safari can not parse date format returned by swift e.g. 2019-12-27 15:46:59 +0000 (fallback used because we trust that safari will learn it in future because chrome knows that format)
coords: {
latitude: latitude,
longitude: longitude,
altitude: altitude,
accuracy: accuracy,
altitudeAccuracy: altitudeAccuracy,
heading: (heading > 0) ? heading : null,
speed: (speed > 0) ? speed : null
}
};
for (var id in this.listeners) {
this.listeners[id].success(position);
}
this.clear(false);
},
error: function(code, message) {
var error = {
PERMISSION_DENIED: 1,
POSITION_UNAVAILABLE: 2,
TIMEOUT: 3,
code: code,
message: message
};
for (var id in this.listeners) {
this.listeners[id].error(error);
}
this.clear(true);
}
};
// @override getCurrentPosition()
navigator.geolocation.getCurrentPosition = function(success, error, options) {
var id = this.helper.id();
this.helper.listeners[id] = { onetime: true, success: success || this.noop, error: error || this.noop };
window.webkit.messageHandlers.listenerAdded.postMessage("");
};
// @override watchPosition()
navigator.geolocation.watchPosition = function(success, error, options) {
var id = this.helper.id();
this.helper.listeners[id] = { onetime: false, success: success || this.noop, error: error || this.noop };
window.webkit.messageHandlers.listenerAdded.postMessage("");
return id;
};
// @override clearWatch()
navigator.geolocation.clearWatch = function(id) {
var idExists = (this.helper.listeners[id]) ? true : false;
if (idExists) {
this.helper.listeners[id] = null;
delete this.helper.listeners[id];
window.webkit.messageHandlers.listenerRemoved.postMessage("");
}
};
""";
return javaScripToEvaluate;
}
// <===
// MARK: - API Calls
func startTrackingSteps() {
......@@ -147,239 +349,268 @@ var timer2: DispatchSourceTimer?
self.startTimer()
}
})
}
// MARK: - WKScriptMessageHandler
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if let event = message.body as? String {
let eventArray = event.split(separator: ":")
if (eventArray[0] == "event") {
if (eventArray[1] == "closeArtwork") {
// Location Permissions
if (message.name == "listenerAdded") {
listenersCount += 1;
self.navigationController?.popViewController(animated: true)
} else if (eventArray[1] == "addUserTag") {
// SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
let questionnaireEvent = swiftApi.QuestionnaireEventModel()
questionnaireEvent._name = String(eventArray[1])
if (eventArray.count > 2) {
questionnaireEvent._parameter = String(eventArray[2])
swiftApi().setUserTag(String(eventArray[2]))
} else {
questionnaireEvent._parameter = ""
swiftApi().setUserTag("")
if (!locationServicesIsEnabled()) {
onLocationServicesIsDisabled();
}
else if (authorizationStatusIsDenied(status: CLLocationManager.authorizationStatus())) {
onAuthorizationStatusIsDenied();
}
else if (authorizationStatusNeedRequest(status: CLLocationManager.authorizationStatus())) {
onAuthorizationStatusNeedRequest();
}
else if (authorizationStatusIsGranted(status: CLLocationManager.authorizationStatus())) {
onAuthorizationStatusIsGranted();
}
}
else if (message.name == "listenerRemoved") {
listenersCount -= 1;
// no listener left in web view to wait for position
if (listenersCount == 0) {
locationManager.stopUpdatingLocation();
}
}
// <==
else if (message.name == "Cosmote") {
if let event = message.body as? String {
let eventArray = event.split(separator: ":")
if (eventArray[0] == "event") {
if (eventArray[1] == "closeArtwork") {
self.navigationController?.popViewController(animated: true)
} else if (eventArray[1] == "addUserTag") {
// SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
let questionnaireEvent = swiftApi.QuestionnaireEventModel()
questionnaireEvent._name = String(eventArray[1])
if (eventArray.count > 2) {
questionnaireEvent._parameter = String(eventArray[2])
swiftApi().setUserTag(String(eventArray[2]))
} else {
questionnaireEvent._parameter = ""
swiftApi().setUserTag("")
}
SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
SwiftEventBus.post("campaigns_retrieved")
}
SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
SwiftEventBus.post("campaigns_retrieved")
} else {
}
} else {
}
}
} else {
}
}
} else if (eventArray[1] == "couponRetrieved") {
let couponEvent = swiftApi.CouponEventModel()
SwiftEventBus.post("coupon_retrieved", sender: couponEvent)
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
}
} else {
}
} else {
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
}
} else {
}
}
} else if (eventArray[1] == "ccmsRetrieved") {
let ccmsEnabled = swiftApi.WarplyCCMSEnabledModel()
ccmsEnabled._isActivated = true
SwiftEventBus.post("ccms_enabled", sender: ccmsEnabled)
} else if (eventArray[1] == "couponShared") {
}
} else if (eventArray[1] == "couponRetrieved") {
let couponEvent = swiftApi.CouponEventModel()
SwiftEventBus.post("coupon_retrieved", sender: couponEvent)
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
else if (eventArray[1] == "steps" && eventArray[2] == "widgetDisabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = false
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
} else if (eventArray[1] == "steps" && eventArray[2] == "widgetEnabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = true
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
}
else if (eventArray[1] == "steps" && eventArray[2] == "shortcutEnabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = true
SwiftEventBus.post("pacing", sender: pacingEvent)
if (swiftApi().getTrackingStepsEnabled() == false) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_steps_activation"
firebaseEvent._parameters = nil
SwiftEventBus.post("firebase", sender: firebaseEvent)
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
}
self.startTrackingSteps()
}
} else if (eventArray[1] == "steps" && eventArray[2] == "shortcutDisabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = false
SwiftEventBus.post("pacing", sender: pacingEvent)
swiftApi().stopTrackingSteps()
} else if (eventArray[1] == "request" || eventArray[1] == "response") {
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 = ""
}
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
}
var type: String = ""
if (eventArray.count > 3) {
type = String(eventArray[3])
} else {
type = ""
}
}
} else if (eventArray[1] == "ccmsRetrieved") {
let ccmsEnabled = swiftApi.WarplyCCMSEnabledModel()
ccmsEnabled._isActivated = true
SwiftEventBus.post("ccms_enabled", sender: ccmsEnabled)
} else if (eventArray[1] == "couponShared") {
}
else if (eventArray[1] == "steps" && eventArray[2] == "widgetDisabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = false
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
} else if (eventArray[1] == "steps" && eventArray[2] == "widgetEnabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = true
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
}
else if (eventArray[1] == "steps" && eventArray[2] == "shortcutEnabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = true
SwiftEventBus.post("pacing", sender: pacingEvent)
if (swiftApi().getTrackingStepsEnabled() == false) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_steps_activation"
firebaseEvent._parameters = nil
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", name)
firebaseEvent.setParameter = ("type", type)
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.startTrackingSteps()
}
} else if (eventArray[1] == "steps" && eventArray[2] == "shortcutDisabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = false
SwiftEventBus.post("pacing", sender: pacingEvent)
swiftApi().stopTrackingSteps()
} else if (eventArray[1] == "request" || eventArray[1] == "response") {
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)
} else if (eventArray[1] == "refreshToken") {
var access_token: String = ""
if (eventArray.count > 2) {
access_token = String(eventArray[2])
} else {
access_token = ""
}
var refresh_token: String = ""
if (eventArray.count > 3) {
refresh_token = String(eventArray[3])
} else {
refresh_token = ""
} 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)
} else if (eventArray[1] == "refreshToken") {
var access_token: String = ""
if (eventArray.count > 2) {
access_token = String(eventArray[2])
} else {
access_token = ""
}
var refresh_token: String = ""
if (eventArray.count > 3) {
refresh_token = String(eventArray[3])
} else {
refresh_token = ""
}
if (access_token != "" && refresh_token != "") {
swiftApi().updateRefreshToken(access_token: access_token, refresh_token: refresh_token)
}
}
if (access_token != "" && refresh_token != "") {
swiftApi().updateRefreshToken(access_token: access_token, refresh_token: refresh_token)
}
}
}
}
}
......
......@@ -403,6 +403,11 @@
<constraint firstItem="bHn-Kz-pbS" firstAttribute="leading" secondItem="iPT-gj-hEL" secondAttribute="leading" id="UTz-nY-JvS"/>
<constraint firstItem="bHn-Kz-pbS" firstAttribute="top" secondItem="iPT-gj-hEL" secondAttribute="top" id="WKD-3C-3kF"/>
</constraints>
<variation key="default">
<mask key="subviews">
<exclude reference="bHn-Kz-pbS"/>
</mask>
</variation>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="xUc-yV-Y8f"/>
......