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} +