Is updateApplicationContext supposed to trigger didReceiveApplicationContext?

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.

func update(applicationContext: [String: Any]) -> Void { ... } is your own function, right? It's not one of WCSession's methods.

From the code above, that method calls updateApplicationContext on the session, so the delegate is receiving a new application context. That's why WCSession's didReceiveApplicationContext is being called.

But it doesn't make much sense to do what you're doing. The session on the Watch is supposed to receive a new application context from the iOS app, not from itself.

Thanks for your answer.

The func update(applicationContext: [String: Any]) -> Void { ... } function is my custom function used to update the applicationContext from the watch-side. The intention is to do some action on the iOS app when the applicationContext is updated from the watch. 

It was my understanding that this action was supposed to take place on the WCSession object. Is there any other way to achieve this functionality?

Is updateApplicationContext supposed to trigger didReceiveApplicationContext?
 
 
Q