@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.
Files changed (2) hide show
  1. package/README.md +229 -204
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,204 +1,229 @@
1
- # React Native Patriot Native
2
-
3
- [![npm version](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native.svg)](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Platform](https://img.shields.io/badge/platform-react--native-lightgrey)](https://reactnative.dev/)
6
-
7
- > 🚀 Seamlessly install WearOS watch faces and retrieve device information directly from your React Native mobile application.
8
-
9
- ## What's New in v1.0.5
10
-
11
- - 🔍 **Device Detection**: New `getConnectedWatchProperties()` function
12
- - 📱 **Multi-Platform Support**: Detect WearOS, Fitbit, and other wearable devices
13
- - 🏷️ **Device Information**: Get name, platform, type, and unique ID
14
- - 🛡️ **Enhanced Error Handling**: Improved disconnection detection
15
-
16
- ## 🚀 Quick Start
17
-
18
- ```bash
19
- npm install @haykmkrtich/react-native-patriot-native
20
- ```
21
-
22
- ```typescript
23
- import { installWatchface, getConnectedWatchProperties } from '@haykmkrtich/react-native-patriot-native';
24
-
25
- // Install watchface
26
- await installWatchface('com.example.watchface.package');
27
-
28
- // Get device info
29
- const watch = await getConnectedWatchProperties();
30
- console.log(`Connected: ${watch.displayName} (${watch.platform})`);
31
- ```
32
-
33
- ## 📋 Requirements
34
-
35
- - ⚛️ React Native 0.60.0
36
- - 🤖 Android API level 21+ (Android 5.0+)
37
- - Paired WearOS device
38
-
39
- ## 🎯 Features
40
-
41
- | Feature | Description |
42
- |---------|-------------|
43
- | 📦 **Watch Face Installation** | Install watch faces directly on paired WearOS devices |
44
- | 🔍 **Device Detection** | Retrieve detailed information about connected devices |
45
- | 🏷️ **Platform Detection** | Identify WearOS, Fitbit, and other wearable platforms |
46
- | 📡 **Connection Status** | Monitor device connectivity and proximity |
47
- | 🔄 **Promise-based API** | Modern async/await support |
48
- | 💬 **Native Feedback** | Toast notifications for user feedback |
49
-
50
- ## 📖 API Reference
51
-
52
- ### `installWatchface(packageName: string)`
53
-
54
- Initiates watch face installation on connected WearOS device.
55
-
56
- ```typescript
57
- try {
58
- await installWatchface('com.example.watchface.package');
59
- // Installation initiated successfully
60
- } catch (error) {
61
- // ❌ Handle installation errors
62
- }
63
- ```
64
-
65
- **Errors:**
66
- - `NO_NODES` - No connected WearOS device
67
- - `INSTALL_FAILED` - Installation process failed
68
-
69
- ### `getConnectedWatchProperties()`
70
-
71
- Retrieves detailed information about connected wearable devices.
72
-
73
- ```typescript
74
- interface WatchProperties {
75
- id: string; // Unique device identifier
76
- displayName: string; // Human-readable device name
77
- isNearby: boolean; // Device proximity status
78
- type: string; // Device type (e.g., "watch")
79
- platform: string; // Platform ("wearOS" | "fitbit")
80
- isDisconnected?: boolean; // No device connected
81
- }
82
- ```
83
-
84
- **Example Response:**
85
- ```typescript
86
- // Connected Device
87
- {
88
- id: "node_12345_abcdef",
89
- displayName: "Galaxy Watch 4",
90
- isNearby: true,
91
- type: "watch",
92
- platform: "wearOS"
93
- }
94
-
95
- // ❌ No Device
96
- { isDisconnected: true }
97
- ```
98
-
99
- ## 🔧 Setup Requirements
100
-
101
- ### Android Dependencies
102
-
103
- Add to your `android/app/build.gradle`:
104
-
105
- ```gradle
106
- dependencies {
107
- implementation 'com.google.android.gms:play-services-wearable:18.1.0'
108
- implementation 'androidx.wear:wear-remote-interactions:1.0.0'
109
- }
110
- ```
111
-
112
- ### WearOS Development Best Practices
113
-
114
- > ⚠️ **Important**: For Google Play Console compliance, create **two applications** with identical package names:
115
- > - 📱 Mobile companion app (React Native)
116
- > - ⌚ WearOS watch face app
117
-
118
- This ensures proper functionality and distribution through Google Play Store.
119
-
120
- ## 🛠️ How It Works
121
-
122
- ```mermaid
123
- graph LR
124
- A[Mobile App] --> B[WearOS Remote API]
125
- B --> C[Connected Watch]
126
- C --> D[Google Play Store]
127
- D --> E[Watch Face Installation]
128
- ```
129
-
130
- 1. **Device Discovery** - Scan for connected WearOS devices
131
- 2. **Remote Installation** - Send installation request to watch
132
- 3. **Play Store Integration** - Open watch face listing on device
133
- 4. **User Confirmation** - User confirms installation on watch
134
-
135
- ## 💡 Usage Examples
136
-
137
- ### Basic Installation
138
- ```typescript
139
- import { installWatchface } from '@haykmkrtich/react-native-patriot-native';
140
-
141
- const handleInstall = async (packageName: string) => {
142
- try {
143
- await installWatchface(packageName);
144
- console.log('✅ Check your watch for installation prompt');
145
- } catch (error) {
146
- console.error('❌ Installation failed:', error.message);
147
- }
148
- };
149
- ```
150
-
151
- ### Device Information
152
- ```typescript
153
- import { getConnectedWatchProperties } from '@haykmkrtich/react-native-patriot-native';
154
-
155
- const checkWatchStatus = async () => {
156
- try {
157
- const watch = await getConnectedWatchProperties();
158
-
159
- if (watch.isDisconnected) {
160
- return '❌ No watch connected';
161
- }
162
-
163
- return `✅ ${watch.displayName} (${watch.platform}) - ${watch.isNearby ? 'Nearby' : 'Away'}`;
164
- } catch (error) {
165
- return `❌ Detection failed: ${error.message}`;
166
- }
167
- };
168
- ```
169
-
170
- ## 🤝 Contributing
171
-
172
- Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) before submitting PRs.
173
-
174
- 1. Fork the repository
175
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
176
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
177
- 4. Push to the branch (`git push origin feature/amazing-feature`)
178
- 5. Open a Pull Request
179
-
180
- ## 📄 License
181
-
182
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
183
-
184
- ## 👨‍💻 Author
185
-
186
- **Hayk Mkrtich**
187
- - GitHub: [@HaykMkrtich](https://github.com/HaykMkrtich)
188
- - NPM: [@haykmkrtich](https://www.npmjs.com/~haykmkrtich)
189
-
190
- ## 🆘 Support
191
-
192
- - 🐛 **Bug Reports**: [Create an issue](https://github.com/HaykMkrtich/react-native-patriot-native/issues/new?template=bug_report.md)
193
- - 💡 **Feature Requests**: [Request a feature](https://github.com/HaykMkrtich/react-native-patriot-native/issues/new?template=feature_request.md)
194
- - 📖 **Documentation**: [View full docs](https://github.com/HaykMkrtich/react-native-patriot-native/wiki)
195
-
196
- ---
197
-
198
- <div align="center">
199
-
200
- **⭐ Star this repository if it helped you!**
201
-
202
- Made with ❤️ for the React Native community
203
-
204
- </div>
1
+ # React Native Patriot Native
2
+
3
+ [![npm version](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native.svg)](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Platform](https://img.shields.io/badge/platform-react--native-lightgrey)](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
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@haykmkrtich/react-native-patriot-native",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.ts",
5
5
  "files": [
6
6
  "index.ts",
7
7
  "src/",
8
- "android/"
8
+ "android/",
9
+ "README.md"
9
10
  ],
10
11
  "keywords": [
11
12
  "react-native",