Ember Router and WKWebview interaction

Hello,

We are building an iOS app which makes use of a wkwebview to run a dashboard page which used to be served from rails hence had proper http requests delivering the html and everything else. We have moved on and replaced that page with an ember app which of cause is a single page app where not really page requests happen anymore. IOS provides a few ways to hook into the webview loading to determine when a page was loaded, errored and so on. Now with ember all of that only works on the first page request. So in order to at least know when a url has changed and finished loading or errored I need to build some sort of message system between the webapp and native app. Its fairly easy to provide a global class or function to the webview which lets the webapp send a message back into the iOS app to call a handler but I am wondering if ember itself perhaps already thought of that and issues custom events during the routing / or error substates. If events would be fired we could simple create event listener and call the native code without any code changes in our web app (using the provided class or func in the app router service). Hope someone could help me with that.

1 Like

Hi @teejay. I don’t think Ember itself will fire any custom events for page changes, so it sounds like you will need some small changes to the web app for this. The RouterService provides a routeDidChange hook which should have all the information you need to call an injected global API, or fire your own custom events.

Yeah cool, thats what I thought , no big deal. Thanks for responding.

1 Like