rn-watch-connectv2.0

Watch status

Check whether a Watch is paired, has your Watch app installed, and is reachable right now.

These properties tell you what the Session can do right now. Each read returns the current value, and they never throw.

PropertyTypetrue when
isWatchSupportedbooleanThis iPhone supports WatchConnectivity.
isWatchPairedbooleanAn Apple Watch is paired with this iPhone.
isWatchAppInstalledbooleanYour Watch app is installed on the paired Watch.
isWatchReachablebooleanYour Watch app can receive a Message right now.
watchActivationStateWatchActivationState(A string, not a boolean.) Whether the Session is ready to carry data.

Three of them have an event that fires when the value changes: onReachabilityChanged, onWatchPairedChanged and onWatchAppInstallChanged.

Events fire only on a real change

A new listener isn't called with the current value. Read the property for the starting value, then listen for changes. With useEvent, pass the property as the initial value:

import {  } from "expo";
import  from "rn-watch-connect";

export function () {
  const {  } = (, "onReachabilityChanged", {
    : .,
  });
  return  ? "Watch reachable" : "Watch not reachable";
}

isWatchSupported

readonly isWatchSupported: boolean

true when this iPhone supports WatchConnectivity. It's false on an iPad, and on platforms other than iOS. Check it before showing any Watch features.

Example

import  from "rn-watch-connect";

if (!.) {
  // Hide your Watch features.
}

isWatchPaired

readonly isWatchPaired: boolean

true when an Apple Watch is paired with this iPhone. Listen to onWatchPairedChanged for changes. It's false on platforms other than iOS.

isWatchAppInstalled

readonly isWatchAppInstalled: boolean

true when your Watch app is installed on the paired Watch. Listen to onWatchAppInstallChanged for changes. It's false on platforms other than iOS.

isWatchReachable

readonly isWatchReachable: boolean

true when your Watch app can receive a Message right now, because it's running and in range. Only Messages and Data Messages need it: sending one while it's false fails with ERR_WATCH_NOT_REACHABLE. Application Context, User Info and File Transfers are delivered later instead. Listen to onReachabilityChanged for changes. It's false on platforms other than iOS.

Example

import  from "rn-watch-connect";

if (.) {
  await .({ : true });
} else {
  .({ : true });
}

watchActivationState

readonly watchActivationState: WatchActivationState
// "notActivated" | "inactive" | "activated" | "unknown"

Whether the Session is ready to carry data.

ValueMeaning
"activated"The Session is ready.
"inactive"The Session is finishing up, for example while the iPhone switches to another Watch.
"notActivated"The Session isn't activated yet.
"unknown"WatchConnectivity isn't supported: on an iPhone without it, and on platforms other than iOS.

The Session activates when the library loads. There's no event for a failed activation: if watchActivationState still isn't "activated" shortly after launch, activation failed.

Example

import  from "rn-watch-connect";

(() => {
  if (. !== "activated") {
    .("The Session didn't activate:", .);
  }
}, 2000);

onReachabilityChanged

onReachabilityChanged: (event: { isWatchReachable: boolean }) => void

Fires when isWatchReachable changes. It fires only on a real change, so read the property for the starting value.

Event

FieldTypeDescription
isWatchReachablebooleanThe new value of isWatchReachable.

Example

import {  } from "expo";
import  from "rn-watch-connect";

export function () {
  (, "onReachabilityChanged", ({  }) => {
    .("Watch reachable:", );
  });
  return null;
}

onWatchPairedChanged

onWatchPairedChanged: (event: { isWatchPaired: boolean }) => void

Fires when isWatchPaired changes. It fires only on a real change, so read the property for the starting value.

Event

FieldTypeDescription
isWatchPairedbooleanThe new value of isWatchPaired.

Example

import {  } from "expo";
import  from "rn-watch-connect";

export function () {
  const {  } = (, "onWatchPairedChanged", {
    : .,
  });
  return  ? "Watch paired" : "No Watch paired";
}

onWatchAppInstallChanged

onWatchAppInstallChanged: (event: { isWatchAppInstalled: boolean }) => void

Fires when isWatchAppInstalled changes. It fires only on a real change, so read the property for the starting value.

Event

FieldTypeDescription
isWatchAppInstalledbooleanThe new value of isWatchAppInstalled.

Example

import {  } from "expo";
import  from "rn-watch-connect";

export function () {
  const {  } = (, "onWatchAppInstallChanged", {
    : .,
  });
  return  ? "Watch app installed" : "Install the Watch app";
}

On this page