Hi, I am new to swift and IOS development, I was developing an app which can be used to communicating between Apple Watch and iPhone.
Something strange occurred when I was trying to observe the status of the message(UserInfo) sent by func transferUserInfo(_ userInfo: [String : Any] = [:]) -> WCSessionUserInfoTransfer.
I was trying to observe isTransferring(a boolean value) in WCSessionUserInfoTransfer which was returned by the function mentioned above, but it seems cannot be updated even if the message queue was empty, it seems to always be True.
Here is my sample code:
let transfer = session.transferUserInfo(message)
if transfer.isTransferring {
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in
print("Queued message count: \(self.session.outstandingUserInfoTransfers.count), isTransferring:\(transfer.isTransferring)")
if !transfer.isTransferring {
timer.invalidate()
// irrelevant codes...
}
}
} else {
// other irrelevant codes...
}
Appreciate if anyone can help me out of this problem.
Best wishes.