Watch kit controller WKInterfaceController
suggest changeThis must live in a WKInterfaceController that adopts WCSessionDelegate. As written it is not inside a type. awake(withContext:) and WCSession.default() are Swift 3 names.
import WatchConnectivity
var watchSession : WCSession?
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
startWatchSession()
}
func startWatchSession(){
if(WCSession.isSupported()){
watchSession = WCSession.default()
watchSession!.delegate = self
watchSession!.activate()
}
}
//Callback in below delegate method when iOS app triggers event
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) {
print("did ReceiveApplicationContext at watch")
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents