{"id":13838511,"url":"https://github.com/AlexisLeon/react-native-watch","last_synced_at":"2025-07-10T23:31:22.624Z","repository":{"id":57341398,"uuid":"104517803","full_name":"AlexisLeon/react-native-watch","owner":"AlexisLeon","description":"React Native bindings for WatchKit","archived":false,"fork":false,"pushed_at":"2018-08-22T14:59:01.000Z","size":11,"stargazers_count":29,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-21T02:33:27.682Z","etag":null,"topics":["react-native","watchkit"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-watch","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexisLeon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-22T20:52:04.000Z","updated_at":"2023-01-06T20:57:12.000Z","dependencies_parsed_at":"2022-09-14T04:30:24.465Z","dependency_job_id":null,"html_url":"https://github.com/AlexisLeon/react-native-watch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AlexisLeon/react-native-watch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexisLeon%2Freact-native-watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexisLeon%2Freact-native-watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexisLeon%2Freact-native-watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexisLeon%2Freact-native-watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexisLeon","download_url":"https://codeload.github.com/AlexisLeon/react-native-watch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexisLeon%2Freact-native-watch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264687866,"owners_count":23649576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-native","watchkit"],"created_at":"2024-08-04T16:00:19.915Z","updated_at":"2025-07-10T23:31:22.383Z","avatar_url":"https://github.com/AlexisLeon.png","language":"Objective-C","funding_links":[],"categories":["Library"],"sub_categories":["Plugin"],"readme":"# React Native Watch\n\n[![Travis](https://img.shields.io/travis/alexisleon/react-native-watch.svg?maxAge=2592000)](https://travis-ci.org/alexisleon/react-native-watch)\n[![npm version](https://img.shields.io/npm/v/react-native-watch.svg)](https://www.npmjs.com/package/react-native-watch)\n[![npm dm](https://img.shields.io/npm/dm/react-native-watch.svg)](https://www.npmjs.com/package/react-native-watch)\n[![npm dt](https://img.shields.io/npm/dt/react-native-watch.svg)](https://www.npmjs.com/package/react-native-watch)\n\n\n***This is a beta release***\n\n*Requirements:*\n\n* `react-native \u003e= 0.41.2` for iOS\n\nConnect your React Native App with WatchKit.\n\n***Android Wear support coming soon..***\n\n## Getting started\n\n```\nyarn add react-native-watch\n```\n\nLink the library to your project automatically by using:\n\n```\nreact-native link react-native-watch\n```\n\nOr manually, by adding `node_modules/react-native-watch/RNWatch.xcodeproj` to your project and adding `libRNWatch.a` to `Build Phases` ➜ `Link Binary With Libraries`\n\nOnce linked to your project, modify `AppDelegate.h`:\n\n```diff\n#import \u003cUIKit/UIKit.h\u003e\n+ #import \u003cWatchConnectivity/WatchConnectivity.h\u003e\n\n+ @class RNWatch;\n\n@interface AppDelegate : UIResponder \u003cUIApplicationDelegate\u003e\n\n@property (nonatomic, strong) UIWindow *window;\n+ @property (nonatomic, strong) RNWatch *watchBridge;\n+ @property (nonatomic, strong) WCSession *session;\n\n@end\n```\n\nAnd modify `AppDelegate.m`\n\n```diff\n#import \"AppDelegate.h\"\n+ #import \"RNWatch.h\"\n\n...\n\n -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n  ...\n+  self.watchBridge = [RNWatch shared];\n+  self.session = self.watchBridge.session;\n\n  return YES;\n```\n\n## Usage\n\nUse the examples below to start sending data between React Native and WatchOS (Swift)\n\n**ES5**\n```javascript\nvar watch = require('react-native-watch')\n```\n\n**ES6**\n```javascript\nimport * as watch from 'react-native-watch'\n```\n\n### Messages\n\n#### Receive messages\n\nSubscribe and unsubscribe to all messages.\n\n```javascript\n// Subscribe\ncomponentDidMount() {\n  this.messageSubscription = watch.subscribeToMessages(\n    (err, message) =\u003e {\n      if (err) console.error('Error receiving message', err)\n      else {\n        ...\n      }\n    }\n  )\n}\n\n// Unsubscribe\ncomponentWillUnmount() {\n  // messageSubscription -\u003e remove function waiting to be called\n  this.messageSubscription()\n}\n```\n\n#### Send Message\n\nSend messages and receive a response\n\n```javascript\nwatch.sendMessage(data, (err, res) =\u003e {\n  if (err) console.error('Error sending message to watch', err)\n  else {\n    console.log('Watch received the message sent')\n    if (res) {\n      console.log('Watch replied', res)\n    }\n  }\n})\n```\n\n## Testing\n\n```bash\nyarn run test\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/alexisleon/react-native-watch/tags).\n\n## Authors\n\n* **Alexis Leon** - *Initial work* - [AlexisLeon](https://github.com/AlexisLeon)\n\nSee also the list of [contributors](https://github.com/alexisleon/react-native-watch/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* Inspirited by [Conor Buckley](https://github.com/conorbuck/react-native-watch.git)\n* Inspirited by [Michael Ford](https://github.com/mtford90/react-native-watch-connectivity)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexisLeon%2Freact-native-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlexisLeon%2Freact-native-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexisLeon%2Freact-native-watch/lists"}