Szukaj…


Wprowadzenie

WCSessionDelegate współpracuje z zegarkiem OS2 + za pomocą WatchConnectivity. var watchSession: WCSession? func startWatchSession () {if (WCSession.isSupported ()) {watchSession = WCSession.default () watchSession! .delegate = self watchSession! .activate ()}} Zaimplementuj wymaganą metodę: - didReceiveApplicationContext

Oglądaj kontroler zestawu (WKInterfaceController)

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")
    }


Modified text is an extract of the original Stack Overflow Documentation
Licencjonowany na podstawie CC BY-SA 3.0
Nie związany z Stack Overflow