I understand that you actually want a test scenario.
But which direction for communication do you want to test? If you check documentation of WCSession
it always states the behavior for the watch and the iOS device.
Furthermore, what do you mean with 'disconnected'?
You can check for WCSession.defaultSession().reachable
but documentation states
On iOS, the value is YES when the paired Apple Watch is in range and
the associated Watch app is running in the foreground.
You can check for paired
, but you also need to check for watchAppInstalled
.
I believe that all communication is asynchronous. Do you want to check your errorHandler:
code as in
- (void)sendMessageData:(NSData *)data
replyHandler:(void (^)(NSData *replyMessageData))replyHandler
errorHandler:(void (^)(NSError *error))errorHandler
I think it is not possible to test it on a simulator. You could only copy your errorHandler code temporarily to replyHandler for testing.
Here is the code I use for testing the availability:
if WCSession.isSupported() {
let session = WCSession.defaultSession()
session.delegate = _modelController
session.activateSession()
_modelController!.transferArrayToWatchWithSession()
}
and within the _modelController
func transferArrayToWatchWithSession() {
let session = WCSession.defaultSession()
if WCSession.isSupported() && session.watchAppInstalled {
session.transferUserInfo([kWatchControlsDictKey:self.verifiedWatchArray])
} else {
log.info(....")
}
}