Installation
Requirements, installing the library, and a first Message to the Watch.
Requirements
- Expo SDK 57 or later (React Native 0.86+)
- iOS 16.4 or later
- A companion watchOS app to talk to
The library is iOS only. On other platforms, its methods fail with ERR_UNSUPPORTED_PLATFORM and watchActivationState is "unknown".
On an older Expo SDK, or supporting iOS 15?
Stay on rn-watch-connect@1.x. Its docs are in the 1.2.0 README.
Installation
npm install rn-watch-connectThe library has native code, so rebuild the native app after installing or upgrading it, for example with npx expo run:ios or a new development build. A JS reload isn't enough, and it doesn't run in Expo Go.
Quick start
Send a Message when the Watch is reachable, and listen for Messages from it:
import { } from "expo";
import from "rn-watch-connect";
export function () {
(, "onMessageReceived", () => {
.("From the Watch:", );
});
async function () {
if (!.) return;
const = await .({ : .() });
.("Reply:", );
}
return null; // Call ping() from a button.
}When something fails, the error has a stable code, such as ERR_WATCH_NOT_REACHABLE. Match on it, never on message. See Error codes.