ios - didReceiveApplicationContext method in background WatchOS/WatchConnectivity -


i calling updateapplicationcontext method in appdelegate in order check , send user name apple watch.

nsdictionary *applicationdict = @{@"status" : m.customer.first_name}; [[wcsession defaultsession] updateapplicationcontext:applicationdict error:nil]; 

when watch app in background , ios app wakes up. updateapplicationcontext method in ios called , didreceiveapplicationcontext method called in watchos. however, can not set text of label when didreceiveapplicationcontext called when watch app in background. if watch app active when didreceiveapplicationcontext called text of label changed.

delegate method in watchos:

func session(session: wcsession, didreceiveapplicationcontext applicationcontext: [string : anyobject]){         let message : string = applicationcontext["status"] as! string         messagelabel.settext(message)     } 

what can reason of problem? should keep value fetched when watch app in background , change text when willactivate called?

put

func session(session: wcsession, didreceiveapplicationcontext applicationcontext: [string : anyobject]){     let message : string = applicationcontext["status"] as! string     messagelabel.settext(message) } 

method in extension delegate catch updates if app in background or in viewcontroller when active. had same issue turns out didreceiveapplicationcontext method gets called expected. testing need few seconds data in background. started app , confused label didn't update. problem data delivered after view controller went active.


Comments