0

I am calling the

`[[WCSession defaultSession] updateApplicationContext:message error:error]` 

method which is triggered in my

 `-(void)session:(WCSession *)session didReceiveApplicationContext:(NSDictionary<NSString *,id> *)applicationContext`

method in ExtensionDelegate. But from here I want to call a public method in a WKInterfaceController to update my UI. I don't want to reload the root controllers as this particular controller is not the root controller. Is it possible to call any public method from ExtensionDelegate. Can I call

-(void)session:(WCSession *)session didReceiveApplicationContext:(NSDictionary<NSString *,id> *)applicationContext

from somewhere within Interface controller instead of ExtensionDelegate?

JMS
  • 271
  • 4
  • 15

1 Answers1

0

You can use WCSession's

public func sendMessage(message: [String : AnyObject], replyHandler: (([String : AnyObject]) -> Void)?, errorHandler: ((NSError) -> Void)?) 

this will invoke WCSessionDelegate's

public func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void)

method in delegate class. This can be used from both app and extension for instantaneous message transfer. Read more

Akhilrajtr
  • 5,170
  • 3
  • 19
  • 30
  • Problem is I have to call update UI method based on timer. The updateApplicationContext method is called on timer invocation and this is called from my watchConnectivityManager. When this method is called, it triggers the corresponding recieveApplicationContext method present in ExtensionDelegate. What I want to know is can recieveApplicationContext method be called from within any interfaceController instead of ExtensionDelegate – JMS Jan 27 '16 at 10:10