diff --git a/README.md b/README.md
index 70162de..09325b5 100644
--- a/README.md
+++ b/README.md
@@ -65,10 +65,50 @@ Add the following entry to your `android/app/src/main/AndroidManifest.xml` (full
android:permission="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
-
+
```
+### Wear OS application setup
+
+To communicate from a React Native Wear OS app, add the library to your watch
+project and declare the Wear OS feature in the manifest:
+
+```xml
+
+
+
+
+```
+
+Example component that sends a message to the paired phone and updates the UI
+when a message is received:
+
+```tsx
+import React, { useEffect, useState } from 'react';
+import { View, Text, Button } from 'react-native';
+import { sendMessage, watchEvents } from 'react-native-wear-connectivity';
+
+export default function WearApp() {
+ const [count, setCount] = useState(0);
+
+ useEffect(() => {
+ const unsubscribe = watchEvents.on('message', () => {
+ setCount((c) => c + 1);
+ });
+
+ return () => unsubscribe();
+ }, []);
+
+ return (
+
+ The count is {count}
+
+ );
+}
+```
+
## React Native API Documentation
The example of implementation available in the [CounterScreen](example/src/CounterScreen/index.android.tsx).
diff --git a/src/index.tsx b/src/index.tsx
index 14d1dcf..2563ed8 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -2,6 +2,7 @@ import { AppRegistry } from 'react-native';
import { NativeModules, Platform } from 'react-native';
import { watchEvents } from './subscriptions';
import { sendMessage } from './messages';
+import WearOSConnector from './wearos/WearOSConnector';
import type {
ReplyCallback,
ErrorCallback,
@@ -37,7 +38,13 @@ const startFileTransfer: SendFile = (file, _metadata) => {
return WearConnectivity.sendFile(file, _metadata);
};
-export { startFileTransfer, sendMessage, watchEvents, WearConnectivity };
+export {
+ startFileTransfer,
+ sendMessage,
+ watchEvents,
+ WearConnectivity,
+ WearOSConnector,
+};
export type { ReplyCallback, ErrorCallback };
type WearParameters = {
diff --git a/src/wearos/WearOSConnector.ts b/src/wearos/WearOSConnector.ts
new file mode 100644
index 0000000..cd034ef
--- /dev/null
+++ b/src/wearos/WearOSConnector.ts
@@ -0,0 +1,49 @@
+import type { Payload, ReplyCallback, ErrorCallback } from '../NativeWearConnectivity';
+import { sendMessage } from '../messages';
+import { watchEvents } from '../subscriptions';
+
+/**
+ * Simple helper class that forwards messages between the React Native app and the Wear OS app.
+ *
+ * It wraps the existing `sendMessage` API and exposes a convenient method to
+ * subscribe to incoming messages coming from the Wear OS companion application.
+ */
+class WearOSConnector {
+ private unsubscribe?: () => void;
+
+ /**
+ * Register a listener for messages coming from the Wear OS app.
+ *
+ * @param listener Callback invoked every time a message is received.
+ * @returns Function to remove the registered listener.
+ */
+ connect(listener: (message: Payload) => void) {
+ this.unsubscribe = watchEvents.on('message', listener);
+ return this.unsubscribe;
+ }
+
+ /**
+ * Remove the current message listener, if any.
+ */
+ disconnect() {
+ if (this.unsubscribe) {
+ this.unsubscribe();
+ this.unsubscribe = undefined;
+ }
+ }
+
+ /**
+ * Send a message to the Wear OS app.
+ *
+ * @param message Message payload to send.
+ * @param cb Optional callback invoked on success.
+ * @param errCb Optional callback invoked on error.
+ */
+ send(message: Payload, cb?: ReplyCallback, errCb?: ErrorCallback) {
+ sendMessage(message, cb, errCb);
+ }
+}
+
+const connector = new WearOSConnector();
+export default connector;
+export type { Payload };
diff --git a/watch-example/package.json b/watch-example/package.json
index 8fbd2fc..69b4f07 100644
--- a/watch-example/package.json
+++ b/watch-example/package.json
@@ -11,7 +11,8 @@
},
"dependencies": {
"react": "18.2.0",
- "react-native": "0.73.4"
+ "react-native": "0.73.4",
+ "react-native-wear-connectivity": "file:.."
},
"devDependencies": {
"@babel/core": "^7.20.0",