Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Run swift code on main thread in react-native

$
0
0

I am trying to make a react-native app cast to chromecast. The chromecast GCKDeviceScanner has to run on the main thread.

The react native page says to run on main thread you have to do this:

- (dispatch_queue_t)methodQueue{  return dispatch_get_main_queue();}

I am not very familiar with swift or ios, so where do I put this code, and how do I use it? I have my method:

let filterCriteria = GCKFilterCriteria(forAvailableApplicationWithID: "myApp")    let deviceScanner = GCKDeviceScanner(filterCriteria: filterCriteria)    if let deviceScanner = deviceScanner {      deviceScanner.addListener(self)      deviceScanner.startScan()      deviceScanner.passiveScan = true    }

Any idea on how I can run my code on the main thread?


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>