How to use react-native-watch-connectivity - 8 common examples

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 BlueWallet / BlueWallet / WatchConnectivity.ios.js View on Github external
getIsWatchAppInstalled() {
    Watch.getIsWatchAppInstalled((err, isAppInstalled) => {
      if (!err) {
        WatchConnectivity.shared.isAppInstalled = isAppInstalled;
        Watch.subscribeToWatchState((err, watchState) => {
          if (!err) {
            if (watchState === 'Activated') {
              WatchConnectivity.shared.sendWalletsToWatch();
            }
          }
        });
        Watch.subscribeToMessages(async (err, message, reply) => {
          if (!err) {
            if (message.request === 'createInvoice') {
              const createInvoiceRequest = await this.handleLightningInvoiceCreateRequest(
                message.walletIndex,
                message.amount,
                message.description,
github rdev / now-mobile / src / Provider.js View on Github external
});
		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();
			}
		});
	};
github BlueWallet / BlueWallet / WatchConnectivity.ios.js View on Github external
Watch.getIsWatchAppInstalled((err, isAppInstalled) => {
      if (!err) {
        WatchConnectivity.shared.isAppInstalled = isAppInstalled;
        Watch.subscribeToWatchState((err, watchState) => {
          if (!err) {
            if (watchState === 'Activated') {
              WatchConnectivity.shared.sendWalletsToWatch();
            }
          }
        });
        Watch.subscribeToMessages(async (err, message, reply) => {
          if (!err) {
            if (message.request === 'createInvoice') {
              const createInvoiceRequest = await this.handleLightningInvoiceCreateRequest(
                message.walletIndex,
                message.amount,
                message.description,
              );
              reply({ invoicePaymentRequest: createInvoiceRequest });
            } else if (message.message === 'sendApplicationContext') {
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();
			}
		});
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();
			}
		});
	};
github jitsi / jitsi-meet / react / features / mobile / watchos / middleware.js View on Github external
function _appWillMount({ dispatch, getState }) {
    watch.subscribeToWatchReachability((error, reachable) => {
        dispatch(setWatchReachable(reachable));
        _updateApplicationContext(getState);
    });

    watch.subscribeToMessages((error, message) => {
        if (error) {
            logger.error('watch.subscribeToMessages error:', error);

            return;
        }

        const {
            command,
            sessionID
        } = message;
        const currentSessionID = _getSessionId(getState());

        if (!sessionID || sessionID !== currentSessionID) {
            logger.warn(
                `Ignoring outdated watch command: ${message.command}`
                    + ` sessionID: ${sessionID} current session ID: ${currentSessionID}`);
github jitsi / jitsi-meet / react / features / mobile / watchos / middleware.js View on Github external
function _appWillMount({ dispatch, getState }) {
    watch.subscribeToWatchReachability((error, reachable) => {
        dispatch(setWatchReachable(reachable));
        _updateApplicationContext(getState);
    });

    watch.subscribeToMessages((error, message) => {
        if (error) {
            logger.error('watch.subscribeToMessages error:', error);

            return;
        }

        const {
            command,
            sessionID
        } = message;
        const currentSessionID = _getSessionId(getState());
github jitsi / jitsi-meet / react / features / mobile / watchos / middleware.js View on Github external
function _updateApplicationContext(stateful) {
    const state = toState(stateful);
    const { conferenceTimestamp, sessionID, watchReachable } = state['features/mobile/watchos'];

    if (!watchReachable) {
        return;
    }

    try {
        watch.updateApplicationContext({
            conferenceTimestamp,
            conferenceURL: getCurrentConferenceUrl(state),
            micMuted: _isAudioMuted(state),
            recentURLs: _getRecentUrls(state),
            sessionID
        });
    } catch (error) {
        logger.error('Failed to stringify or send the context', error);
    }
}