Hi,
I am working on an apple watch app project linked to an iOS App(made with React-native).
I realized that when I update the current applicationContext from the watch-side with the updateApplicationContext
function, the didReceiveApplicationContext
function also gets triggered on the watch-side.
I was not expecting updating the applicationContext to trigger the receiving function.
Is this behavior expected? Or could it be that I'm missing something while setting up the WCSession singleton object?
This is my code for the singleton connectivity object.
extension ConnectivityProvider {
// function to update applicationContext
func update(applicationContext: [String: Any]) -> Void {
DispatchQueue.main.async {
do {
print("applicationContext update")
try self.session.updateApplicationContext(applicationContext)
print("new applicationContext: \(applicationContext)")
} catch {
print("applicationContext update failed")
}
}
}
// function to receive applicationContextUpdate
func session(_ session: WCSession, didReceiveApplicationContextapplicationContext: [String: Any]) -> Void {
DispatchQueue.main.async {
print("updated context from couterpart: \(applicationContext)")
}
}
}
Thank you in advance for your help.