Showing
1 changed file
with
30 additions
and
6 deletions
| ... | @@ -29,26 +29,50 @@ import SwiftEventBus | ... | @@ -29,26 +29,50 @@ import SwiftEventBus |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { | 31 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { |
| 32 | - print("=== event callback ===") | 32 | + |
| 33 | - print(message.name, message.body) | ||
| 34 | - print("=== event callback ===") | ||
| 35 | - | ||
| 36 | if let event = message.body as? String { | 33 | if let event = message.body as? String { |
| 37 | let eventArray = event.split(separator: ":") | 34 | let eventArray = event.split(separator: ":") |
| 38 | 35 | ||
| 39 | if (eventArray[0] == "event") { | 36 | if (eventArray[0] == "event") { |
| 40 | if (eventArray[1] == "closeArtwork") { | 37 | if (eventArray[1] == "closeArtwork") { |
| 38 | + self.navigationController?.popViewController(animated: true) | ||
| 41 | 39 | ||
| 42 | } else if (eventArray[1] == "addUserTag") { | 40 | } else if (eventArray[1] == "addUserTag") { |
| 43 | let questionnaireEvent = swiftApi.QuestionnaireEventModel() | 41 | let questionnaireEvent = swiftApi.QuestionnaireEventModel() |
| 44 | - questionnaireEvent._name = String(eventArray[0]) | 42 | + questionnaireEvent._name = String(eventArray[1]) |
| 45 | - questionnaireEvent._parameter = String(eventArray[1]) | 43 | + questionnaireEvent._parameter = String(eventArray[2]) |
| 46 | SwiftEventBus.post("questionnaire", sender: questionnaireEvent) | 44 | SwiftEventBus.post("questionnaire", sender: questionnaireEvent) |
| 47 | 45 | ||
| 48 | swiftApi().setUserTag(String(eventArray[2])) | 46 | swiftApi().setUserTag(String(eventArray[2])) |
| 49 | 47 | ||
| 50 | } else if (eventArray[1] == "couponRetrieved") { | 48 | } else if (eventArray[1] == "couponRetrieved") { |
| 49 | + let couponEvent = swiftApi.CouponEventModel() | ||
| 50 | + SwiftEventBus.post("coupon_retrieved", sender: couponEvent) | ||
| 51 | + | ||
| 52 | + } else if (eventArray[2] == "serviceDisabled") { | ||
| 53 | + let pacingService = swiftApi.WarplyPacingCardServiceEnabledModel() | ||
| 54 | + pacingService._isEnabled = false | ||
| 55 | + SwiftEventBus.post("pacing_service", sender: pacingService) | ||
| 56 | + | ||
| 57 | + } else if (eventArray[2] == "serviceEnabled") { | ||
| 58 | + let pacingService = swiftApi.WarplyPacingCardServiceEnabledModel() | ||
| 59 | + pacingService._isEnabled = true | ||
| 60 | + SwiftEventBus.post("pacing_service", sender: pacingService) | ||
| 61 | + | ||
| 62 | + } else if (eventArray[2] == "shortcutEnabled") { | ||
| 63 | + let pacingEvent = swiftApi.WarplyPacingCardEventModel() | ||
| 64 | + pacingEvent._isVisible = true | ||
| 65 | + SwiftEventBus.post("pacing_visible", sender: pacingEvent) | ||
| 66 | + | ||
| 67 | + } else if (eventArray[2] == "shortcutDisabled") { | ||
| 68 | + let pacingEvent = swiftApi.WarplyPacingCardEventModel() | ||
| 69 | + pacingEvent._isVisible = false | ||
| 70 | + SwiftEventBus.post("pacing_visible", sender: pacingEvent) | ||
| 51 | 71 | ||
| 72 | + } else if (eventArray[1] == "request" || eventArray[1] == "response") { | ||
| 73 | + print("**************** WARPLY Webview Log START *****************") | ||
| 74 | + print(eventArray[2]) | ||
| 75 | + print("**************** WARPLY Webview Log END *****************") | ||
| 52 | } | 76 | } |
| 53 | } | 77 | } |
| 54 | } | 78 | } | ... | ... |
-
Please register or login to post a comment