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-08-02 14:01:38 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
61578d7ff038d23988ff0e8623ec3324ce4b0f48
61578d7f
1 parent
10706736
send data in webview via JS
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/GiftsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/CampaignViewController.swift
View file @
61578d7
...
...
@@ -14,6 +14,7 @@ import SwiftEventBus
@IBOutlet
weak
var
webview
:
WKWebView
!
public
var
campaignUrl
:
String
=
""
public
var
params
:
String
=
""
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -34,6 +35,20 @@ import SwiftEventBus
webview
.
configuration
.
userContentController
.
add
(
self
,
name
:
"Cosmote"
)
}
// MARK: - WKNavigationDelegate
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
let
scriptSource
=
"passParams(
\(
params
)
);"
webView
.
evaluateJavaScript
(
scriptSource
,
completionHandler
:
{
(
object
,
error
)
in
print
(
"==== object ===="
)
print
(
object
)
print
(
"==== error ===="
)
print
(
error
)
})
}
// MARK: - WKScriptMessageHandler
public
func
userContentController
(
_
userContentController
:
WKUserContentController
,
didReceive
message
:
WKScriptMessage
)
{
if
let
event
=
message
.
body
as?
String
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/GiftsViewController.swift
View file @
61578d7
...
...
@@ -172,6 +172,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"CampaignViewController"
)
as!
SwiftWarplyFramework
.
CampaignViewController
var
url
=
""
var
params
=
""
let
isCcmsOffer
=
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
!=
nil
)
&&
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
!=
""
)
&&
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
==
"true"
)
if
(
isCcmsOffer
)
{
...
...
@@ -187,9 +188,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
}
url
=
swiftApi
()
.
constructCcmsUrl
(
campaigns
[
indexPath
.
row
],
ccmsCampaignFound
)
params
=
swiftApi
()
.
constructCcmsParams
(
campaigns
[
indexPath
.
row
],
ccmsCampaignFound
)
}
else
{
url
=
swiftApi
()
.
constructCampaignUrl
(
campaigns
[
indexPath
.
row
])
params
=
swiftApi
()
.
constructCampaignParams
(
campaigns
[
indexPath
.
row
])
}
...
...
@@ -201,6 +204,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
else
{
url
=
swiftApi
()
.
constructCampaignUrl
(
campaigns
[
indexPath
.
row
])
params
=
swiftApi
()
.
constructCampaignParams
(
campaigns
[
indexPath
.
row
])
let
encoder
=
JSONEncoder
()
encoder
.
outputFormatting
=
.
prettyPrinted
...
...
@@ -210,6 +214,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
print
(
"CampaignUrl url onclick: "
+
url
)
vc
.
campaignUrl
=
url
vc
.
params
=
params
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
else
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
View file @
61578d7
...
...
@@ -125,6 +125,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"CampaignViewController"
)
as!
SwiftWarplyFramework
.
CampaignViewController
var
url
=
""
var
params
=
""
let
isCcmsOffer
=
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
!=
nil
)
&&
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
!=
""
)
&&
(
campaigns
[
indexPath
.
row
]
.
ccms_offer
==
"true"
)
if
(
isCcmsOffer
)
{
...
...
@@ -140,9 +141,11 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
}
url
=
swiftApi
()
.
constructCcmsUrl
(
campaigns
[
indexPath
.
row
],
ccmsCampaignFound
)
params
=
swiftApi
()
.
constructCcmsParams
(
campaigns
[
indexPath
.
row
],
ccmsCampaignFound
)
}
else
{
url
=
swiftApi
()
.
constructCampaignUrl
(
campaigns
[
indexPath
.
row
])
params
=
swiftApi
()
.
constructCampaignParams
(
campaigns
[
indexPath
.
row
])
}
...
...
@@ -154,6 +157,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
else
{
url
=
swiftApi
()
.
constructCampaignUrl
(
campaigns
[
indexPath
.
row
])
params
=
swiftApi
()
.
constructCampaignParams
(
campaigns
[
indexPath
.
row
])
let
encoder
=
JSONEncoder
()
encoder
.
outputFormatting
=
.
prettyPrinted
...
...
@@ -163,6 +167,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
print
(
"CampaignUrl url onclick: "
+
url
)
vc
.
campaignUrl
=
url
vc
.
params
=
params
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
61578d7
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment