NACCWatchAppContentViewWatchDelegate

class NACCWatchAppContentViewWatchDelegate : NSObject, WCSessionDelegate

This class exists to give the Watch Connectivity a place to work.

  • This is a template for the update callback.

    Declaration

    Swift

    typealias ApplicationContextHandler = (_ inApplicationContext: [String : Any]) -> Void

    Parameters

    inApplicationContext

    The new application context.

  • Just here to satisfy the protocol.

  • Just here to satisfy the protocol.

  • This will be called when the context changes. This is always called in the main thread.

    Declaration

    Swift

    var updateHandler: ApplicationContextHandler?
  • This maintains a reference to the session.

    Declaration

    Swift

    private static var _wcSession: WCSession
  • This is a simple semaphore, to indicate that an update to/from the peer is in progress.

    Declaration

    Swift

    var isUpdateInProgress: Bool
  • This is used for trying to recover from Watch sync errors.

    Declaration

    Swift

    var retries: Int
  • Called when an activation change occurs.

    Declaration

    Swift

    func session(_ inSession: WCSession, activationDidCompleteWith inActivationState: WCSessionActivationState, error inError: (any Error)?)

    Parameters

    inSession

    The session experiencing the activation change.

    activationDidCompleteWith

    The new state.

    error

    If there was an error, it is sent in here.

  • Called when the application context is updated from the peer.

    Declaration

    Swift

    func session(_ inSession: WCSession, didReceiveApplicationContext inApplicationContext: [String : Any])

    Parameters

    inSession

    The session receiving the context update.

    didReceiveApplicationContext

    The new context data.

  • Called when the session deactivates.

    Declaration

    Swift

    func wcSessionDidBecomeInactive(_ inSession: WCSession)

    Parameters

    inSession

    The session being deactivated.

  • Called when a context update request message from the watch, is received on the phone.

  • This sends a message to the phone (from the watch), that is interpreted as a request for a context update.

    See more

    Declaration

    Swift

    func sendContextRequest(_ inRetries: Int = 5)
  • This is called to send the current state of the prefs to the peer.

    Declaration

    Swift

    func sendApplicationContext()
  • Initializer

    Declaration

    Swift

    init(updateHandler inUpdateHandler: ApplicationContextHandler?)

    Parameters

    updateHandler

    The function that will be called with any updates.