Reputation: 69
Can we build a React Native wearable Application?
Especially on companion mode.
Please provide any companion mode react native sample apps, if there are any.Thanks
Upvotes: 1
Views: 3064
Reputation: 5942
Video Preview: https://github.com/fabOnReact/react-native-wear-connectivity/assets/24992535/415fab47-7d76-4c72-80b9-c0d19ec25a49
yarn add react-native-wear-connectivity
npx react-native@latest init YourMobileAppName
<!-- this file is located at android/app/src/main/AndroidManifest.xml -->
<uses-feature android:name="android.hardware.type.watch" />
yarn start --port=8082
yarn android
, open the react native dev menu and change the bundle location to your-ip:8082
(for ex. 192.168.18.2:8082
).You can now build the app with yarn android
. JS fast-refresh and the other metro functionalities work without problem.
import { sendMessage } from 'react-native-wear-connectivity';
sendMessage({ text: 'Hello watch!' });
import { watchEvents } from 'react-native-wear-connectivity';
const unsubscribe = watchEvents.on('message', (message) => {
console.log('received message from watch', message);
});
Upvotes: 0
Reputation: 6967
Currently React Native not officially support Wearables but you can use React native vanilla
Upvotes: 2