@@ -14,6 +14,7 @@ enum WeLoopWebAction: String, CaseIterable {
1414 case getCapture = " WeloopGetCapture "
1515 case getCurrentUser = " GetCurrentUser "
1616 case setNotificationCount = " SetNotificationCount "
17+ case isLoaded = " IsLoaded "
1718}
1819
1920class WeLoopViewController : UIViewController {
@@ -113,8 +114,12 @@ class WeLoopViewController: UIViewController {
113114 }
114115
115116 func sendCurrentUser( ) {
116- guard let uuid = WeLoop . shared. apiKey, let token = WeLoop . shared. authenticationToken else { return }
117- webView? . evaluateJavaScript ( " GetCurrentUser({ appGuid: ' \( uuid) ', token: ' \( token) '}) " )
117+ guard let uuid = WeLoop . shared. apiKey else { return }
118+ if let token = WeLoop . shared. authenticationToken {
119+ webView? . evaluateJavaScript ( " GetCurrentUser({ appGuid: ' \( uuid) ', token: ' \( token) '}) " )
120+ } else {
121+ webView? . evaluateJavaScript ( " GetCurrentUser({ appGuid: ' \( uuid) '}) " )
122+ }
118123 }
119124}
120125
@@ -131,6 +136,9 @@ extension WeLoopViewController: WKScriptMessageHandler {
131136 case . setNotificationCount:
132137 guard let body = message. body as? [ String : Any ] , let count = body [ " number " ] as? Int else { return }
133138 WeLoop . shared. setNotificationBadge ( count: count)
139+ case . isLoaded:
140+ indicator. stopAnimating ( )
141+ webView. backgroundColor = . clear
134142 }
135143 }
136144}
@@ -152,11 +160,4 @@ extension WeLoopViewController: WKNavigationDelegate {
152160 }
153161 }
154162 }
155-
156- func webView( _ webView: WKWebView , didFinish navigation: WKNavigation ! ) {
157- indicator. stopAnimating ( )
158- //TODO: commented out for now, but at this point the load is finished (files have been loaded) and the spa should render
159- // a loader. This is not done immediately so there is a little lag, but I can't do anything more on the native side.
160- //webView.backgroundColor = .clear
161- }
162163}
0 commit comments