수색…


소개

WCSessionDelegateWCSessionDelegate 사용하여 OS2 +를 시청합니다. var watchSession : WCSession? 필요한 메소드를 구현하십시오 : - didReceiveApplicationContext () 메소드를 구현하십시오 : func startWatchSession () {if (WCSession.isSupported ()) {watchSession = WCSession.default () watchSession.delegate = self watchSession.activate ()}}

감시 키트 컨트롤러 (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
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow