{"_id":"@d4l/react-native-wear-connectivity","_rev":"5-980a8c7c0213fb0d59b7fc36527c26bc","name":"@d4l/react-native-wear-connectivity","dist-tags":{"latest":"0.3.1"},"versions":{"0.2.1":{"name":"@d4l/react-native-wear-connectivity","version":"0.2.1","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/fabOnReact","name":"Fabrizio Bertoglio","email":"fabrizio.bertoglio@gmail.com"},"license":"MIT","_id":"@d4l/react-native-wear-connectivity@0.2.1","contributors":[{"url":"https://github.com/gesundsheitcloud","name":"Claire Mouton","email":"claire.mouton@data4life.care"}],"homepage":"https://github.com/gesundheitscloud/react-native-wear-connectivity#readme","bugs":{"url":"https://github.com/gesundheitscloud/react-native-wear-connectivity/issues"},"dist":{"shasum":"8268d0dcec19ee7880cd0dd7a5b9e8b94a7a2220","tarball":"https://registry.npmjs.org/@d4l/react-native-wear-connectivity/-/react-native-wear-connectivity-0.2.1.tgz","fileCount":76,"integrity":"sha512-2Lg22+2oWut8S0y5NuDNSlIc/YpnrBsmzU9LWYlo7aUCde7FmuuHLI0hx30l29dzkm4Sb599Oc01gm3aoF5/xA==","signatures":[{"sig":"MEUCIHBtfLHJmArqySEMeyZTdlm9ooAWeYt25FNpQcAnZN/0AiEAsSkVim8613KezcL/ax71e4j2uiMpeREqryBp016PRYg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":77262},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"lib/commonjs/index","types":"lib/typescript/src/index.d.ts","module":"lib/module/index","source":"src/index","engines":{"node":">= 18.0.0"},"gitHead":"c2c4c7d14968306aa85149accc25e6b7efa9654f","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","example":"yarn workspace react-native-phone-connectivity-example","prepare":"bob build","release":"release-it","typecheck":"tsc --noEmit","watch-example":"yarn workspace react-native-wear-connectivity-example"},"_npmUser":{"name":"d4l-team","email":"frontend@data4life.care"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"repository":{"url":"git+https://github.com/gesundheitscloud/react-native-wear-connectivity.git","type":"git"},"workspaces":["example","watch-example"],"_npmVersion":"10.8.1","description":"Enstablish a two-way connection with wearOS","directories":{},"resolutions":{"@types/react":"17.0.21"},"_nodeVersion":"22.3.0","eslintConfig":{"root":true,"rules":{"prettier/prettier":["error",{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"}]},"extends":["@react-native","prettier"]},"eslintIgnore":["node_modules/","lib/"],"react-native":"src/index","codegenConfig":{"name":"RNWearConnectivitySpec","type":"modules","jsSrcsDir":"src"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.6.1","devDependencies":{"jest":"^28.1.1","react":"18.2.0","turbo":"^1.10.7","eslint":"latest","del-cli":"^5.0.0","prettier":"^2.0.5","commitlint":"^17.0.2","release-it":"^15.0.0","typescript":"^5.0.2","@types/jest":"^28.1.2","pod-install":"^0.1.0","@types/react":"~17.0.21","react-native":"0.73.4","eslint-plugin-jest":"^27.6.3","@types/react-native":"0.70.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","react-native-builder-bob":"^0.20.0","@typescript-eslint/parser":"latest","@react-native/eslint-config":"^0.72.2","@commitlint/config-conventional":"^17.0.2","@typescript-eslint/eslint-plugin":"latest","@release-it/conventional-changelog":"^5.0.0"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-wear-connectivity_0.2.1_1719229420157_0.9760158667452281","host":"s3://npm-registry-packages"},"react-native-builder-bob":{"output":"lib","source":"src","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]}},"0.3.0":{"name":"@d4l/react-native-wear-connectivity","version":"0.3.0","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/fabOnReact","name":"Fabrizio Bertoglio","email":"fabrizio.bertoglio@gmail.com"},"license":"MIT","_id":"@d4l/react-native-wear-connectivity@0.3.0","maintainers":[{"name":"d4l-team","email":"frontend@data4life.care"}],"homepage":"https://github.com/gesundsheitcloud/react-native-wear-connectivity#readme","bugs":{"url":"https://github.com/gesundsheitcloud/react-native-wear-connectivity/issues"},"dist":{"shasum":"cf319fc40ea6dbb20a69453e77bfd556c6d2114d","tarball":"https://registry.npmjs.org/@d4l/react-native-wear-connectivity/-/react-native-wear-connectivity-0.3.0.tgz","fileCount":76,"integrity":"sha512-eG1R5xFVPnaigP6XGudgDv6lGrT5UbO+8K6/i5YaIKlqLflQ7AKaj5DiCH4d+0duQkFcRAv9QjOcMJhGtiJrdw==","signatures":[{"sig":"MEYCIQDBAsoc0yNG+mcr4YOXk3dKupmwP3KkkRIXI+VqgRq2RQIhAM8VRi1RrgLpHV1Lba9aCm9gzKSj/2ryA5ZVO8coWn1i","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":82220},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"lib/commonjs/index","types":"lib/typescript/src/index.d.ts","module":"lib/module/index","source":"src/index","engines":{"node":">= 18.0.0"},"gitHead":"a975ff89b655c5eeedaea9c6001399c940fe751b","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","example":"yarn workspace react-native-phone-connectivity-example","prepare":"bob build","release":"release-it","typecheck":"tsc --noEmit","watch-example":"yarn workspace react-native-wear-connectivity-example"},"_npmUser":{"name":"d4l-team","email":"frontend@data4life.care"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"repository":{"url":"git+https://github.com/gesundsheitcloud/react-native-wear-connectivity.git","type":"git"},"workspaces":["example","watch-example"],"_npmVersion":"10.8.3","description":"Establish a two-way connection with wearOS","directories":{},"resolutions":{"@types/react":"17.0.21"},"_nodeVersion":"22.3.0","eslintConfig":{"root":true,"rules":{"prettier/prettier":["error",{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"}]},"extends":["@react-native","prettier"]},"eslintIgnore":["node_modules/","lib/"],"react-native":"src/index","codegenConfig":{"name":"RNWearConnectivitySpec","type":"modules","jsSrcsDir":"src"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.6.1","devDependencies":{"jest":"^28.1.1","react":"18.2.0","turbo":"^1.10.7","eslint":"latest","del-cli":"^5.0.0","prettier":"^2.0.5","commitlint":"^17.0.2","release-it":"^15.0.0","typescript":"^5.0.2","@types/jest":"^28.1.2","pod-install":"^0.1.0","@types/react":"~17.0.21","react-native":"0.73.4","eslint-plugin-jest":"^27.6.3","@types/react-native":"0.70.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","react-native-builder-bob":"^0.20.0","@typescript-eslint/parser":"latest","@react-native/eslint-config":"^0.72.2","@commitlint/config-conventional":"^17.0.2","@typescript-eslint/eslint-plugin":"latest","@release-it/conventional-changelog":"^5.0.0"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-wear-connectivity_0.3.0_1741885159858_0.18616233473303478","host":"s3://npm-registry-packages-npm-production"},"react-native-builder-bob":{"output":"lib","source":"src","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]}},"0.3.1":{"name":"@d4l/react-native-wear-connectivity","version":"0.3.1","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/fabOnReact","name":"Fabrizio Bertoglio","email":"fabrizio.bertoglio@gmail.com"},"license":"MIT","_id":"@d4l/react-native-wear-connectivity@0.3.1","maintainers":[{"name":"d4l-team","email":"frontend@data4life.care"}],"homepage":"https://github.com/gesundsheitcloud/react-native-wear-connectivity#readme","bugs":{"url":"https://github.com/gesundsheitcloud/react-native-wear-connectivity/issues"},"dist":{"shasum":"5d8df61a2828ca25bd43c5c48da359feae3bc58b","tarball":"https://registry.npmjs.org/@d4l/react-native-wear-connectivity/-/react-native-wear-connectivity-0.3.1.tgz","fileCount":76,"integrity":"sha512-+tfGrqFmp+0ZIXrHHuPj2ir2t+Aj9cre+O3OwTxIneUxRBhEX2Bh59cQb+yno85jOcsNNu9H0MJli7udpIgI1A==","signatures":[{"sig":"MEYCIQDAFLBA1VTdgB8FxH5aItGTDtaeJUP5rpsaFVcM6fQMJQIhAIAOWbP50Ly7TB3kVYHOHMarDMbDMup59gfxmfz1w9Qo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":82220},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"lib/commonjs/index","types":"lib/typescript/src/index.d.ts","module":"lib/module/index","source":"src/index","engines":{"node":">= 18.0.0"},"gitHead":"a5abad1919245c169605779dccfb37f448bcaf7f","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","example":"yarn workspace react-native-phone-connectivity-example","prepare":"bob build","release":"release-it","typecheck":"tsc --noEmit","watch-example":"yarn workspace react-native-wear-connectivity-example"},"_npmUser":{"name":"d4l-team","email":"frontend@data4life.care"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"repository":{"url":"git+https://github.com/gesundsheitcloud/react-native-wear-connectivity.git","type":"git"},"workspaces":["example","watch-example"],"_npmVersion":"10.8.3","description":"Establish a two-way connection with wearOS","directories":{},"resolutions":{"@types/react":"17.0.21"},"_nodeVersion":"22.3.0","eslintConfig":{"root":true,"rules":{"prettier/prettier":["error",{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"}]},"extends":["@react-native","prettier"]},"eslintIgnore":["node_modules/","lib/"],"react-native":"src/index","codegenConfig":{"name":"RNWearConnectivitySpec","type":"modules","jsSrcsDir":"src"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.6.1","devDependencies":{"jest":"^28.1.1","react":"18.2.0","turbo":"^1.10.7","eslint":"latest","del-cli":"^5.0.0","prettier":"^2.0.5","commitlint":"^17.0.2","release-it":"^15.0.0","typescript":"^5.0.2","@types/jest":"^28.1.2","pod-install":"^0.1.0","@types/react":"~17.0.21","react-native":"0.73.4","eslint-plugin-jest":"^27.6.3","@types/react-native":"0.70.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","react-native-builder-bob":"^0.20.0","@typescript-eslint/parser":"latest","@react-native/eslint-config":"^0.72.2","@commitlint/config-conventional":"^17.0.2","@typescript-eslint/eslint-plugin":"latest","@release-it/conventional-changelog":"^5.0.0"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-wear-connectivity_0.3.1_1741885658063_0.03140900864535001","host":"s3://npm-registry-packages-npm-production"},"react-native-builder-bob":{"output":"lib","source":"src","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]}}},"time":{"created":"2024-06-24T11:43:40.156Z","modified":"2025-04-01T18:37:29.214Z","0.2.1":"2024-06-24T11:43:40.298Z","0.3.0":"2025-03-13T16:59:20.041Z","0.3.1":"2025-03-13T17:07:38.242Z"},"bugs":{"url":"https://github.com/gesundsheitcloud/react-native-wear-connectivity/issues"},"author":{"url":"https://github.com/fabOnReact","name":"Fabrizio Bertoglio","email":"fabrizio.bertoglio@gmail.com"},"license":"MIT","homepage":"https://github.com/gesundsheitcloud/react-native-wear-connectivity#readme","keywords":["react-native","ios","android"],"repository":{"url":"git+https://github.com/gesundsheitcloud/react-native-wear-connectivity.git","type":"git"},"description":"Establish a two-way connection with wearOS","maintainers":[{"email":"frontend@data4life.care","name":"d4l-team"},{"email":"tre@gmx.de","name":"davomat"}],"readme":"# react-native-wear-connectivity\n\n- Create a [Wear OS][1] app using react-native\n- Connect two react-native apps (Wear OS and Android mobile app)\n- **Both apps are written in react-native**\n\nhttps://github.com/fabOnReact/react-native-wear-connectivity/assets/24992535/415fab47-7d76-4c72-80b9-c0d19ec25a49\n\n**Note**: This library allows you to write your Android WearOS and Mobile apps in React Native, refer to [react-native-watch-connectivity][2] for Apple Watch development.\n\n[1]: https://wearos.google.com\n[2]: https://github.com/mtford90/react-native-watch-connectivity\n\n# Table of Contents\n\n- [Installation](#installation)\n- [Example of implementation](#example-of-implementation)\n- [How to create a WearOS app using react-native](#how-to-create-a-wearos-app-using-react-native)\n- [API Documentation](#api-documentation)\n- [Contributing](#contributing)\n\n## Installation\n\n```sh\nyarn add react-native-wear-connectivity\n```\n\nor\n\n```sh\nnpm install react-native-wear-connectivity\n```\n\n## Example of implementation\n\nImplementation of the above counter application.\n\n```js\nimport React, { useEffect, useState } from 'react';\nimport { View, Text, Button } from 'react-native';\nimport { sendMessage, watchEvents } from 'react-native-wear-connectivity';\n\nfunction CounterScreen() {\n  const [count, setCount] = useState(0);\n\n  useEffect(() => {\n    const unsubscribe = watchEvents.on('message', () => {\n      setCount((prevCount) => prevCount + 1);\n    });\n\n    return () => {\n      unsubscribe();\n    };\n  }, []);\n\n  const onSuccess = (result) => console.log(result);\n  const onError = (error) => console.log(error);\n\n  const sendMessageToWear = () => {\n    const json = { text: 'hello' };\n    sendMessage(json, onSuccess, onError);\n    sendGenuineMessage('/hello', onSuccess, onError);\n  };\n\n  return (\n    <View>\n      <Text>{count}</Text>\n      <Button title=\"increase counter\" onPress={sendMessageToWear} />\n    </View>\n  );\n}\n```\n\n## How to create a WearOS app using react-native\n\n- Create a new react-native app using the same name as your Mobile app.\n  It is important to use the same name because both apps need to share the same package name (AndroidManifest, build.gradle, the project files) and applicationId (build.gradle).\n\n```sh\nnpx react-native@latest init YourMobileAppName\n```\n\n- Add the following line to the new project AndroidManifest (file ):\n\n```xml\n<!-- this file is located at android/app/src/main/AndroidManifest.xml -->\n<uses-feature android:name=\"android.hardware.type.watch\" />\n```\n\n- Create a new emulator of type [WearOS Large round][22].\n- Pair the Android emulator with the Wear OS emulator. Follow this [instructions][21].\n- Start the metro server on port 8082 with `yarn start --port=8082`\n- Build the project with `yarn android`, open the [react native dev menu][23] and change the bundle location to `your-ip:8082` (for ex. `192.168.18.2:8082`).\n- Repeat the same steps for the Android Phone Emulator and use a different port (for ex. 8081).\n- **Important Note**: Before publishing to Google Play, make sure that both apps are signed using the same key (instructions [here][20])\n\nYou can now build the app with `yarn android`. JS fast-refresh and the other metro functionalities work without problem.\n\n[20]: https://reactnative.dev/docs/next/signed-apk-android\n[21]: https://developer.android.com/training/wearables/get-started/connect-phone\n[22]: https://gist.github.com/assets/24992535/f6cb9f84-dc50-492b-963d-6d9e9396f451 'wear os large round'\n[23]: https://reactnative.dev/docs/debugging\n\n## API Documentation\n\n### Send Messages\n\n```js\nimport {\n  sendMessage,\n  sendGenuineMessage,\n} from 'react-native-wear-connectivity';\n\nsendMessage({ text: 'Hello watch!' });\nsendGenuineMessage('/action');\n```\n\n### Receive Messages\n\n```js\nimport { watchEvents } from 'react-native-wear-connectivity';\n\nconst unsubscribe = watchEvents.on('message', (message) => {\n  console.log('received message from watch', message);\n});\n```\n\n### Get reachable Nodes\n\nOn the react-native phone app:\n\n```js\nimport { getReachableNodes } from 'react-native-wear-connectivity';\n\ntype AndroidNode = {\n  displayName: String,\n  id: String,\n};\n\ngetReachableNodes(\n  (reachableNodes: AndroidNode[]) => {\n    reachableNodes?.forEach(({ displayName, id }: AndroidNode) => {\n      // do what you need with reachable nodes\n    });\n  },\n  (error: String) =>\n    console.error('message sent and received with error: ', error)\n);\n```\n\n### Get Nodes based on Capabilities\n\nOn the watch app: res/values/wear.xml\n\n```xml\n<resources xmlns:tools=\"http://schemas.android.com/tools\"\n           tools:keep=\"@array/android_wear_capabilities\">\n    <string-array name=\"android_wear_capabilities\">\n        <item>my_android_capability</item>\n    </string-array>\n</resources>\n```\n\nOn the react-native phone app:\n\n```js\nimport {\n  getCapableAndReachableNodes,\n  getNonCapableAndReachableNodes,\n} from 'react-native-wear-connectivity';\n\ntype AndroidNode = {\n  displayName: String,\n  id: String,\n};\n\n// https://developer.android.com/training/wearables/data/messages#advertise-capabilities\ngetCapableAndReachableNodes(\n  'my_android_capability',\n  (capableNodes: AndroidNode[]) => {\n    capableNodes?.forEach(({ displayName, id }: AndroidNode) => {\n      // do what you need with non-capable nodes\n    });\n  },\n  (error: String) =>\n    console.error('message sent and received with error: ', error)\n);\n\ngetNonCapableAndReachableNodes(\n  'my_android_capability',\n  (nonCapableNodes: AndroidNode[]) => {\n    nonCapableNodes?.forEach(({ displayName, id }: AndroidNode) => {\n      // do what you need with non-capable nodes\n    });\n  },\n  (error: String) =>\n    console.error('message sent and received with error: ', error)\n);\n```\n\n### Open URI remotely from the react-native app on the Android app\n\n```js\nimport { openRemoteURI } from 'react-native-wear-connectivity';\n\ngetNonCapableAndReachableNodes(\n  'sensorhub_wear',\n  (nonCapableNodes: AndroidNode[]) => {\n    nonCapableNodes?.forEach(({ displayName, id }: AndroidNode) => {\n      openRemoteURI(\n        `http://play.google.com/store/apps/details?id=my.app`,\n        id,\n        () => {\n          console.info(\n            'Open PlayStore Intent sent succesfully to ',\n            displayName\n          );\n        },\n        (error: String) =>\n          console.error('message sent and received with error: ', error)\n      );\n    });\n  }\n);\n```\n\n## FAQ\n\n```\nWearConnectivityModule failed to retrieve nodes with error:\njava.util.concurrent.ExecutionException: com.google.android.gms.common.api.ApiException: 17: API: Wearable.API is not available on this device.\nConnection failed with: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}\n```\n\nThe Android Phone did not install the Wear OS app and did not pair with Wear OS device. Follow this [instructions][21].\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\nFeature requests are discussed in the [issue tracker][40].\n\n[40]: https://github.com/fabOnReact/react-native-wear-connectivity/issues\n\n## License\n\nMIT\n","readmeFilename":"README.md"}