0

With the Google Cast iOS SDK 3.5.6 I had some logic in place to detect and resume a an existing cast session when needed. Something like this:

func connectToDevice(_ device: GCKDevice, sessionId: String?) {
    var resumed = false
    if let session = sessionManager.currentSession {
        if session.device == device {
            session.resume()
            resumed = true
        } else {
            sessionManager.endSession()
        }
    }

    if !resumed {
        sessionManager.startSession(with: device)
    }
}

GCKSession.resume() is deprecated with SDK v4.0.2 however. I am seeing no obvious replacement, and simply ignoring existing sessions is not an option (see below code as an example of what does not work)

func connectToDevice(_ device: GCKDevice, sessionId: String?) {
    if let session = sessionManager.currentSession {
        sessionManager.endSession()  // This doesn't help
    }
    DispatchQueue.main.asyncAfter(.now()+5.0) {   // endSession() is asynchronous, so need to give some time  
        sessionManager.startSession(with: device) // This will fail in situations where 'session' isn't nil
    }
}

How are we expected to handle this situation with SDK v4.x?

Hugo
  • 974
  • 9
  • 21

1 Answers1

0

Yeah, you are correct GCKSession.resume() is deprecated with SDK v4.0.2 and now, the session has only start and stop; By default, the SDK deals with resume internally.

In v4.0.2, I would recommend you to leave resuming sessions to session manager and see whether it can do your work or not.

Sreenu Yatam
  • 166
  • 4