@haykmkrtich/react-native-patriot-native 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -204
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,204 +1,229 @@
|
|
|
1
|
-
# React Native Patriot Native
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://reactnative.dev/)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
This
|
|
183
|
-
|
|
184
|
-
##
|
|
185
|
-
|
|
186
|
-
**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
1
|
+
# React Native Patriot Native
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://reactnative.dev/)
|
|
6
|
+
|
|
7
|
+
A React Native module that enables seamless interaction with WearOS devices — install watch faces, detect connected devices, check app installations, and send messages directly from your mobile app.
|
|
8
|
+
|
|
9
|
+
## Why React Native Patriot Native?
|
|
10
|
+
|
|
11
|
+
Installing watch faces on WearOS traditionally requires users to navigate through their watch's Play Store. This module simplifies the process by allowing direct interaction with WearOS devices from your React Native app — device detection, watch face installation, app status checks, and custom messaging all through a simple Promise-based API.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
| Feature | Description |
|
|
16
|
+
|---------|-------------|
|
|
17
|
+
| **Watch Face Installation** | Install watch faces directly on paired WearOS devices |
|
|
18
|
+
| **Device Detection** | Get detailed info on all connected WearOS devices |
|
|
19
|
+
| **Platform Detection** | Identify WearOS vs other wearable platforms |
|
|
20
|
+
| **App Install Check** | Verify if a specific app is installed on the watch |
|
|
21
|
+
| **Custom Messaging** | Send arbitrary messages to specific watch nodes |
|
|
22
|
+
| **New Architecture** | TurboModule support for React Native 0.77+ |
|
|
23
|
+
| **16KB Page Size** | Compliant with Google Play's 16KB page size requirements |
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @haykmkrtich/react-native-patriot-native
|
|
29
|
+
# or
|
|
30
|
+
yarn add @haykmkrtich/react-native-patriot-native
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Requirements
|
|
34
|
+
|
|
35
|
+
- React Native >= 0.60.0
|
|
36
|
+
- Android API level 24+ (Android 7.0+)
|
|
37
|
+
- Java 17+
|
|
38
|
+
- Paired WearOS device
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
installWatchface,
|
|
45
|
+
getConnectedDevices,
|
|
46
|
+
isAppInstalledOnWatch,
|
|
47
|
+
sendMessageToWatch,
|
|
48
|
+
} from '@haykmkrtich/react-native-patriot-native';
|
|
49
|
+
|
|
50
|
+
// Get all connected devices
|
|
51
|
+
const devices = await getConnectedDevices();
|
|
52
|
+
console.log(devices);
|
|
53
|
+
// [{ id: "node_123", displayName: "Galaxy Watch 4", isNearby: true, type: "watch", platform: "wearOS" }]
|
|
54
|
+
|
|
55
|
+
// Install a watch face
|
|
56
|
+
await installWatchface('com.example.watchface.package');
|
|
57
|
+
|
|
58
|
+
// Check if an app is installed on the watch
|
|
59
|
+
const status = await isAppInstalledOnWatch('com.example.watchface');
|
|
60
|
+
// { isInstalled: true, installedOnNodes: ["node_123"] }
|
|
61
|
+
|
|
62
|
+
// Send a custom message to a specific watch
|
|
63
|
+
await sendMessageToWatch(devices[0].id, '/my-path', 'hello');
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
### `getConnectedDevices(): Promise<ConnectedDevice[]>`
|
|
69
|
+
|
|
70
|
+
Returns all connected WearOS devices with full details. Returns an empty array if no devices are connected.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
interface ConnectedDevice {
|
|
74
|
+
id: string; // Unique device identifier
|
|
75
|
+
displayName: string; // Human-readable device name
|
|
76
|
+
isNearby: boolean; // Device proximity status
|
|
77
|
+
type: string; // Device type (e.g., "watch")
|
|
78
|
+
platform: string; // Platform ("wearOS" | "unknown")
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Example:**
|
|
83
|
+
```typescript
|
|
84
|
+
const devices = await getConnectedDevices();
|
|
85
|
+
|
|
86
|
+
if (devices.length === 0) {
|
|
87
|
+
console.log('No watches connected');
|
|
88
|
+
} else {
|
|
89
|
+
devices.forEach(device => {
|
|
90
|
+
console.log(`${device.displayName} (${device.platform}) - ${device.isNearby ? 'Nearby' : 'Away'}`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Error Codes:**
|
|
96
|
+
- `DETECTION_FAILED` — Failed to communicate with WearOS API
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### `installWatchface(packageName: string): Promise<void>`
|
|
101
|
+
|
|
102
|
+
Initiates watch face installation on all connected WearOS devices.
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
- `packageName` — The Google Play package name of the watch face to install
|
|
106
|
+
|
|
107
|
+
**Example:**
|
|
108
|
+
```typescript
|
|
109
|
+
try {
|
|
110
|
+
await installWatchface('com.awesome.watchface');
|
|
111
|
+
// User will see a toast and installation prompt on their watch
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error.code === 'NO_NODES') {
|
|
114
|
+
console.log('No watch connected');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Error Codes:**
|
|
120
|
+
- `NO_NODES` — No connected WearOS device found
|
|
121
|
+
- `INSTALL_FAILED` — Installation request failed
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### `isAppInstalledOnWatch(packageName: string): Promise<AppInstallStatus>`
|
|
126
|
+
|
|
127
|
+
Checks if a specific app or capability is available on connected watches.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface AppInstallStatus {
|
|
131
|
+
isInstalled: boolean; // Whether the app is found on any watch
|
|
132
|
+
installedOnNodes: string[]; // IDs of watches that have the app
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Example:**
|
|
137
|
+
```typescript
|
|
138
|
+
const status = await isAppInstalledOnWatch('com.example.watchface');
|
|
139
|
+
if (status.isInstalled) {
|
|
140
|
+
console.log(`Installed on ${status.installedOnNodes.length} device(s)`);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Error Codes:**
|
|
145
|
+
- `CHECK_FAILED` — Failed to query capabilities
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `sendMessageToWatch(nodeId: string, path: string, data?: string): Promise<void>`
|
|
150
|
+
|
|
151
|
+
Sends a custom message to a specific watch node. Use `getConnectedDevices()` first to get the node ID.
|
|
152
|
+
|
|
153
|
+
**Parameters:**
|
|
154
|
+
- `nodeId` — Target device ID (from `getConnectedDevices()`)
|
|
155
|
+
- `path` — Message path (e.g., `/my-action`)
|
|
156
|
+
- `data` — Optional string payload (defaults to empty string)
|
|
157
|
+
|
|
158
|
+
**Example:**
|
|
159
|
+
```typescript
|
|
160
|
+
const devices = await getConnectedDevices();
|
|
161
|
+
if (devices.length > 0) {
|
|
162
|
+
await sendMessageToWatch(devices[0].id, '/sync-settings', JSON.stringify({ theme: 'dark' }));
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Error Codes:**
|
|
167
|
+
- `MESSAGE_FAILED` — Failed to send message
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### `getConnectedWatchProperties(): Promise<ConnectedDevice>` *(deprecated)*
|
|
172
|
+
|
|
173
|
+
Returns the first connected device. Use `getConnectedDevices()` instead.
|
|
174
|
+
|
|
175
|
+
## WearOS Development Best Practices
|
|
176
|
+
|
|
177
|
+
This module is designed for WearOS watch face companion apps. For Google Play Console compliance:
|
|
178
|
+
|
|
179
|
+
1. Create **two applications** with identical package names:
|
|
180
|
+
- Mobile companion app (React Native, using this module)
|
|
181
|
+
- WearOS watch face app
|
|
182
|
+
2. This package name consistency is required for proper functionality and distribution through Google Play Store.
|
|
183
|
+
|
|
184
|
+
## How It Works
|
|
185
|
+
|
|
186
|
+
1. **Device Discovery** — Scan for connected WearOS devices via NodeClient
|
|
187
|
+
2. **Remote Installation** — Send installation request to connected watches
|
|
188
|
+
3. **Play Store Integration** — Opens the watch face listing on the watch's Play Store
|
|
189
|
+
4. **User Confirmation** — User confirms installation on their watch
|
|
190
|
+
|
|
191
|
+
## Common Use Cases
|
|
192
|
+
|
|
193
|
+
- Watch face marketplace apps
|
|
194
|
+
- Companion apps for WearOS watch faces
|
|
195
|
+
- Apps that offer multiple watch face styles
|
|
196
|
+
- Enterprise apps managing company-wide watch face deployment
|
|
197
|
+
- Apps that need to communicate with WearOS devices
|
|
198
|
+
|
|
199
|
+
## Changelog
|
|
200
|
+
|
|
201
|
+
### 1.1.0
|
|
202
|
+
- **New:** `getConnectedDevices()` — returns all connected devices with full details (replaces `getConnectedWatchProperties`)
|
|
203
|
+
- **New:** `isAppInstalledOnWatch(packageName)` — check if an app is installed on connected watches
|
|
204
|
+
- **New:** `sendMessageToWatch(nodeId, path, data)` — send custom messages to specific watch nodes
|
|
205
|
+
- **Deprecated:** `getConnectedWatchProperties()` — use `getConnectedDevices()` instead
|
|
206
|
+
- **Fixed:** "No matching variant" build error on React Native 0.78+ / AGP 8.11+
|
|
207
|
+
- Added `publishing` block for AGP 8.11+ compatibility
|
|
208
|
+
- Updated `compileSdk`/`targetSdk` to 35
|
|
209
|
+
- Java 17 compatibility
|
|
210
|
+
- **Fixed:** Duplicate class errors from broken newarch/oldarch stubs — both now have full implementations
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
219
|
+
|
|
220
|
+
## Author
|
|
221
|
+
|
|
222
|
+
**Hayk Mkrtich**
|
|
223
|
+
- GitHub: [@HaykMkrtich](https://github.com/HaykMkrtich)
|
|
224
|
+
- NPM: [@haykmkrtich](https://www.npmjs.com/~haykmkrtich)
|
|
225
|
+
|
|
226
|
+
## Support
|
|
227
|
+
|
|
228
|
+
- [Report Issues](https://github.com/HaykMkrtich/react-native-patriot-native/issues)
|
|
229
|
+
- [Feature Requests](https://github.com/HaykMkrtich/react-native-patriot-native/issues)
|
package/package.json
CHANGED