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-09-09 12:35:24 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b1a3e7911e202677221cb21500999649cc4fbf8a
b1a3e791
1 parent
ab243680
fix real time pacing
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletions
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
View file @
b1a3e79
...
...
@@ -71,7 +71,7 @@ var timer2: DispatchSourceTimer?
DispatchQueue
.
main
.
async
{
// update your model objects and/or UI here
let
metersParam
=
swiftApi
()
.
getMeters
Count
()
let
metersParam
=
swiftApi
()
.
getMeters
Webview
()
let
scriptSource
=
"passMeters(
\(
metersParam
)
);"
self
?
.
webview
.
evaluateJavaScript
(
scriptSource
,
completionHandler
:
{
(
object
,
error
)
in
...
...
@@ -79,6 +79,13 @@ var timer2: DispatchSourceTimer?
print
(
object
)
print
(
"==== error ===="
)
print
(
error
)
swiftApi
()
.
setSavedStepsWebview
(
swiftApi
()
.
getSavedStepsWebview
()
+
swiftApi
()
.
getStepsWebview
())
swiftApi
()
.
setStepsWebview
(
0
)
swiftApi
()
.
setMetersWebview
(
0.0
)
print
(
"==== SavedStepsWebview ===="
)
print
(
swiftApi
()
.
getSavedStepsWebview
())
})
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
b1a3e79
...
...
@@ -23,6 +23,9 @@ public struct GlobalVariables {
static
var
dealsSum
:
Float
=
0.0
static
var
seasonalList
:
Array
<
swiftApi
.
LoyaltyGiftsForYouPackage
>
=
[]
static
var
savedSteps
:
Int
=
0
static
var
stepsWebview
:
Int
=
0
static
var
savedStepsWebview
:
Int
=
0
static
var
metersWebview
:
Double
=
0.0
static
var
merchantList
:
Array
<
swiftApi
.
MerchantModel
>
=
[]
}
...
...
@@ -58,6 +61,30 @@ public class swiftApi {
UserDefaults
.
standard
.
set
(
newValue
,
forKey
:
"metersCount"
)
}
public
func
getStepsWebview
()
->
Int
{
return
GlobalVariables
.
stepsWebview
}
public
func
setStepsWebview
(
_
newValue
:
Int
)
->
Void
{
GlobalVariables
.
stepsWebview
=
newValue
}
public
func
getSavedStepsWebview
()
->
Int
{
return
GlobalVariables
.
savedStepsWebview
}
public
func
setSavedStepsWebview
(
_
newValue
:
Int
)
->
Void
{
GlobalVariables
.
savedStepsWebview
=
newValue
}
public
func
getMetersWebview
()
->
Double
{
return
GlobalVariables
.
metersWebview
}
public
func
setMetersWebview
(
_
newValue
:
Double
)
->
Void
{
GlobalVariables
.
metersWebview
=
newValue
}
public
func
startTrackingSteps
(
_
getStepsCallback
:
@escaping
(
_
steps
:
Int
)
->
Void
)
->
Void
{
...
...
@@ -109,6 +136,16 @@ public class swiftApi {
print
(
"=== MetersCount ==="
)
print
(
metersCount
)
let
newStepsWebview
=
(
steps
as!
Int
)
-
GlobalVariables
.
savedStepsWebview
swiftApi
()
.
setStepsWebview
(
newStepsWebview
)
let
newMetersWebview
=
Double
(
newStepsWebview
)
*
0.762
swiftApi
()
.
setMetersWebview
(
newMetersWebview
)
print
(
"=== StepsWebview ==="
)
print
(
newStepsWebview
)
print
(
"=== MetersWebview ==="
)
print
(
newMetersWebview
)
}
getStepsCallback
(
steps
as?
Int
??
0
)
...
...
@@ -125,6 +162,10 @@ public class swiftApi {
GlobalVariables
.
savedSteps
=
0
swiftApi
()
.
setMetersCount
(
0.0
)
swiftApi
()
.
setStepsWebview
(
0
)
swiftApi
()
.
setSavedStepsWebview
(
0
)
swiftApi
()
.
setMetersWebview
(
0.0
)
let
persistedSteps
=
swiftApi
()
.
getSteps
()
if
(
persistedSteps
>
0
)
{
...
...
Please
register
or
login
to post a comment