Google Cast SDK는 앱이 백그라운드로 전환 될 때 GCKSessionManager.suspendSessionWithReason
을 호출하므로 하나의 해결책은 이유가 .AppBackgrounded
인지 실제로 확인하지 않는 다른 구현으로이 메소드를 대체하는 것입니다.
그런 다음 앱이 백그라운드로 이동해도 SDK가 즉시 세션을 종료하지 않지만 나중에 세션을 일시 중단합니다. 그러나 세션은 백그라운드 모드에서 다시 시작될 수 있습니다. 그러나 상당한 시간이 걸리며 지연은 사용자 관점에서 부정적으로 인식됩니다. 또한 세션은 "이야기하는"것이 아니라 몇 초 후에 정기적으로 다시 중단됩니다.
더 나은 해결책은 여전히 매우 높이 평가됩니다.
extension GCKSessionManager {
static func ignoreAppBackgroundModeChange() {
let oldMethod = class_getInstanceMethod(GCKSessionManager.self, #selector(GCKSessionManager.suspendSessionWithReason))
let newMethod = class_getInstanceMethod(GCKSessionManager.self, #selector(GCKSessionManager.suspendSessionWithReasonIgnoringAppBackgrounded))
method_exchangeImplementations(oldMethod, newMethod)
}
func suspendSessionWithReasonIgnoringAppBackgrounded(reason: GCKConnectionSuspendReason) -> Bool {
guard reason != .AppBackgrounded else { return false }
return suspendSessionWithReason(reason)
}
}
우리가 지금해야 할 일은
은
GCKSessionManager.ignoreAppBackgroundModeChange()
를 호출하는 것입니다.
편집 :
최신 Google 전송 SDK로,이 백그라운드에서 살아 세션을 유지하는 새로운 옵션이 있습니다. 최신 SDK 세션에서
는 이유 "GCKConnectionSuspendReasonNetworkNotReachable" 와 현재 항목의 완료에 장애물을 극복 어떤 방법을 중지됩니다? –