Post

Replies

Boosts

Views

Activity

Top Shelf Extension and Run As Current User
I have an app with a Top Shelf Extension that uses a UserDefaults(suiteName: "app-group-name") to share data between the main app and the extension. I recently enabled the "Run as Current User" capability for both the app itself and the extension. My expectation was that the Top Shelf content would change when the user changes in tvOS but this is not the case. What changes are required such that the Top Shelf content can be changed by tvOS user?
0
1
545
Dec ’20
Proper way to call back into JavaScriptCore from native
In our tvOS app we have a couple of hooks into the native side where we receive events over a WebSocket in (using CocoaAsyncSocket) native and propagate those events into the JavaScript layer. The calls into the JS layer are structured like this:self.receiveQueue.addOperation { websocket.invokeMethod("onmessage", withArguments: [["data": text]]) }Where `receiveQueue` is an `OperationQueue`. This works great most of the time, but we occasionally see application crashes where it seems a memory reference has gone bad. However, we've found that if we take the JavaScript function being called and wrap it in asetTimeout(() => { // Do the work here }, 0)this resolves nearly all the issues. We still get an application crash here and there but the `setTimeout` does the trick most of the time.This leads me to the following question. What's the proper way to call back to a TVJS application from native? Should I be using DispatchQueue.main.async { } instead of an OperationQueue? How does this relate to doing work on the main UI thread?Thanks!
4
0
1.8k
Jun ’18