WatchOS 4

[WatchOS] React-Native 앱에서 데이터 받는 함수

session(_:didReceiveMessage: replyHandler:) func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) { let text = message["text"] as! String self.testLabel.setText(text) } -> RN 앱에서 데이터를 받을 때는 didReceive 함수를 이용해서 받을 수 있다. func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, e..

WatchOS 2021.11.19

[WatchOS] React-Native와 WatchOS 연결하기

우선 React-Native 폴더에서 react-native-watch-connectivity 을 설치해줍니다. npm install react-native-watch-connectivity --save # or yarn add react-native-watch-connectivity 그 후 React-Native 폴더와 WatchKit 폴더를 Link 해주어야 합니다. 1) React-Native 버전이 0.60보다 낮은 경우 react-native link 2) 그 외 경우 (직접 연결) // ios/Podfile pod 'ReactNative 프로젝트이름', :path => '../node_modules/react-native-watch-connectivity' 이후 pod install을 진행해줍..

WatchOS 2021.11.19

[WatchOS] 애플워치에서 데이터 저장하기

이번 글에서는 Xcode에서 애플워치에서 데이터 저장하는 법을 알아보려합니다. 1. 우선 WatchOS 프로젝트를 생성합니다. ios 앱과 연동하려면 첫 번째를 클릭하고 애플워치 앱만으로 만드려면 두 번째를 클릭해서 생성합니다. 2. 우선 위의 그림과 같이 + 버튼을 눌러서 인터페이스로 Button과 Label을 배치합니다. 그러면 이런 화면이 구성이 됩니다. 이제 코드를 보겠습니다. WatchKit Extension 폴더에서 InterfaceController.swfit 파일로 들어갑니다. 그러면 이제 거기에서 // InterfaceController.swift import WatchKit import Foundation class InterfaceController: WKInterfaceControl..

WatchOS 2021.11.11