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]) -> VoidParameters
inApplicationContextThe 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
inSessionThe session experiencing the activation change.
activationDidCompleteWithThe new state.
errorIf 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
inSessionThe session receiving the context update.
didReceiveApplicationContextThe new context data.
-
Called when the session deactivates.
Declaration
Swift
func wcSessionDidBecomeInactive(_ inSession: WCSession)Parameters
inSessionThe 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 moreDeclaration
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
updateHandlerThe function that will be called with any updates.
View on GitHub