@haykmkrtich/react-native-patriot-native
v1.0.6
Published
[](https://badge.fury.io/js/%40haykmkrtich%2Freact-native-patriot-native) [](https://opensource.o
Maintainers
Readme
React Native Patriot Native
🚀 Seamlessly install WearOS watch faces and retrieve device information directly from your React Native mobile application.
✨ What's New in v1.0.5
- 🔍 Device Detection: New
getConnectedWatchProperties()function - 📱 Multi-Platform Support: Detect WearOS, Fitbit, and other wearable devices
- 🏷️ Device Information: Get name, platform, type, and unique ID
- 🛡️ Enhanced Error Handling: Improved disconnection detection
🚀 Quick Start
npm install @haykmkrtich/react-native-patriot-nativeimport { installWatchface, getConnectedWatchProperties } from '@haykmkrtich/react-native-patriot-native';
// Install watchface
await installWatchface('com.example.watchface.package');
// Get device info
const watch = await getConnectedWatchProperties();
console.log(`Connected: ${watch.displayName} (${watch.platform})`);📋 Requirements
- ⚛️ React Native ≥ 0.60.0
- 🤖 Android API level 21+ (Android 5.0+)
- ⌚ Paired WearOS device
🎯 Features
| Feature | Description | |---------|-------------| | 📦 Watch Face Installation | Install watch faces directly on paired WearOS devices | | 🔍 Device Detection | Retrieve detailed information about connected devices | | 🏷️ Platform Detection | Identify WearOS, Fitbit, and other wearable platforms | | 📡 Connection Status | Monitor device connectivity and proximity | | 🔄 Promise-based API | Modern async/await support | | 💬 Native Feedback | Toast notifications for user feedback |
📖 API Reference
installWatchface(packageName: string)
Initiates watch face installation on connected WearOS device.
try {
await installWatchface('com.example.watchface.package');
// ✅ Installation initiated successfully
} catch (error) {
// ❌ Handle installation errors
}Errors:
NO_NODES- No connected WearOS deviceINSTALL_FAILED- Installation process failed
getConnectedWatchProperties()
Retrieves detailed information about connected wearable devices.
interface WatchProperties {
id: string; // Unique device identifier
displayName: string; // Human-readable device name
isNearby: boolean; // Device proximity status
type: string; // Device type (e.g., "watch")
platform: string; // Platform ("wearOS" | "fitbit")
isDisconnected?: boolean; // No device connected
}Example Response:
// ✅ Connected Device
{
id: "node_12345_abcdef",
displayName: "Galaxy Watch 4",
isNearby: true,
type: "watch",
platform: "wearOS"
}
// ❌ No Device
{ isDisconnected: true }🔧 Setup Requirements
Android Dependencies
Add to your android/app/build.gradle:
dependencies {
implementation 'com.google.android.gms:play-services-wearable:18.1.0'
implementation 'androidx.wear:wear-remote-interactions:1.0.0'
}WearOS Development Best Practices
⚠️ Important: For Google Play Console compliance, create two applications with identical package names:
- 📱 Mobile companion app (React Native)
- ⌚ WearOS watch face app
This ensures proper functionality and distribution through Google Play Store.
🛠️ How It Works
graph LR
A[Mobile App] --> B[WearOS Remote API]
B --> C[Connected Watch]
C --> D[Google Play Store]
D --> E[Watch Face Installation]- Device Discovery - Scan for connected WearOS devices
- Remote Installation - Send installation request to watch
- Play Store Integration - Open watch face listing on device
- User Confirmation - User confirms installation on watch
💡 Usage Examples
Basic Installation
import { installWatchface } from '@haykmkrtich/react-native-patriot-native';
const handleInstall = async (packageName: string) => {
try {
await installWatchface(packageName);
console.log('✅ Check your watch for installation prompt');
} catch (error) {
console.error('❌ Installation failed:', error.message);
}
};Device Information
import { getConnectedWatchProperties } from '@haykmkrtich/react-native-patriot-native';
const checkWatchStatus = async () => {
try {
const watch = await getConnectedWatchProperties();
if (watch.isDisconnected) {
return '❌ No watch connected';
}
return `✅ ${watch.displayName} (${watch.platform}) - ${watch.isNearby ? 'Nearby' : 'Away'}`;
} catch (error) {
return `❌ Detection failed: ${error.message}`;
}
};🤝 Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👨💻 Author
Hayk Mkrtich
- GitHub: @HaykMkrtich
- NPM: @haykmkrtich
🆘 Support
- 🐛 Bug Reports: Create an issue
- 💡 Feature Requests: Request a feature
- 📖 Documentation: View full docs
⭐ Star this repository if it helped you!
Made with ❤️ for the React Native community
