How to use the react-native-watch-connectivity.getWatchState function in react-native-watch-connectivity

To help you get started, we’ve selected a few react-native-watch-connectivity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rdev / now-mobile / src / Provider.js View on Github external
setUpWatchConnectivity = () => {
		watch.getWatchReachability((err, watchIsReachable) => {
			this.setState({ watchIsReachable });
		});
		watch.subscribeToWatchReachability((err, watchIsReachable) => {
			if (!err) {
				this.setState({ watchIsReachable });

				if (watchIsReachable) {
					this.sendTokenToWatch();
				}
			}
		});
		watch.getWatchState((err, watchState) => {
			if (!err && watchState === 'Activated') {
				this.sendTokenToWatch();
			}
		});
		watch.subscribeToWatchState((err, watchState) => {
			if (!err && watchState === 'Activated') {
				this.sendTokenToWatch();
			}
		});
	};