Open pepejeria opened 4 years ago
@pepejeria - I’m getting a similar error. Did you figure out the source of this problem?
Hi @robertmryan,
sadly not, it seems like the library is crashing for some reason. I see this crash from time to time in the crash logs, but not a blocker since it happens in the background.
I’m guessing that it’s because I’ve requested both BLE and microphone, but the background documentation says:
Background operations must use the BLE medium only; audio is not supported.
This crash, which as you say, is happening only when the app is in the background, is happening in GNSAudioBroadcastingOperation
. I’m going to try turning off microphone access when it goes into background, and back on when it comes back to foreground.
So far that solution seems promising...
@robertmryan Did it work? What exactly did you do?
@robertmryan @pepejeria Any possible workaround code you could share here?
So, I have a property for the mediums:
#if targetEnvironment(simulator)
private var mediums: GNSDiscoveryMediums = [.audio]
#else
private var mediums: GNSDiscoveryMediums = [.audio, .BLE]
#endif
And in applicationWillResignActive
I just will remove .audio
:
params.strategy = GNSStrategy { [weak self] params in
guard
let params = params,
let self = self
else { return }
params.allowInBackground = background
var mediums = self.mediums
if background {
mediums.remove(.audio)
}
params.discoveryMediums = mediums
}
That's great, thank you for sharing!
The latest version 1.1.1 is causing crashes:
Device states: 100% background
I am not sure if this is the correct place to report bugs, but I couldn't find anywhere else.