sonarfit-react-native 1.0.0 → 2.1.0
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 +59 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ React Native integration for SonarFit SDK - AI-powered workout rep counting for
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- AI-powered rep counting for
|
|
7
|
+
- AI-powered rep counting for Squats, Bench Press, and Deadlifts
|
|
8
8
|
- Real-time workout tracking
|
|
9
9
|
- Support for Apple Watch and AirPods motion sensors
|
|
10
10
|
- Native iOS integration with React Native bridge
|
|
@@ -28,6 +28,28 @@ cd ios && pod install
|
|
|
28
28
|
platform :ios, '17.0'
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
3. Add required permissions to your `Info.plist`:
|
|
32
|
+
```xml
|
|
33
|
+
<key>NSMotionUsageDescription</key>
|
|
34
|
+
<string>This app uses motion sensors to track your workout reps and provide real-time feedback</string>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
4. Enable HealthKit capability:
|
|
38
|
+
- Select your iOS app target in Xcode
|
|
39
|
+
- Go to **Signing & Capabilities**
|
|
40
|
+
- Click **+ Capability**
|
|
41
|
+
- Add **HealthKit**
|
|
42
|
+
- Enable **Background Delivery** under HealthKit
|
|
43
|
+
|
|
44
|
+
5. Add Background Modes to your `Info.plist`:
|
|
45
|
+
```xml
|
|
46
|
+
<key>UIBackgroundModes</key>
|
|
47
|
+
<array>
|
|
48
|
+
<string>fetch</string>
|
|
49
|
+
<string>processing</string>
|
|
50
|
+
</array>
|
|
51
|
+
```
|
|
52
|
+
|
|
31
53
|
## Usage
|
|
32
54
|
|
|
33
55
|
### Initialize the SDK
|
|
@@ -45,7 +67,7 @@ useEffect(() => {
|
|
|
45
67
|
console.error('Failed to initialize SonarFit SDK:', error);
|
|
46
68
|
}
|
|
47
69
|
};
|
|
48
|
-
|
|
70
|
+
|
|
49
71
|
initSDK();
|
|
50
72
|
}, []);
|
|
51
73
|
```
|
|
@@ -57,18 +79,18 @@ import SonarFitSDK, { WorkoutConfig } from 'sonarfit-react-native';
|
|
|
57
79
|
|
|
58
80
|
const startWorkout = async () => {
|
|
59
81
|
const config: WorkoutConfig = {
|
|
60
|
-
workoutType: 'squat',
|
|
82
|
+
workoutType: 'squat', // 'squat' | 'deadlift' | 'benchpress'
|
|
61
83
|
sets: 3,
|
|
62
84
|
reps: 10,
|
|
63
|
-
restTime: 60,
|
|
64
|
-
countdownDuration: 3,
|
|
65
|
-
autoReLift: true,
|
|
66
|
-
deviceType: '
|
|
85
|
+
restTime: 60, // seconds (default: 60)
|
|
86
|
+
countdownDuration: 3, // seconds (default: 3)
|
|
87
|
+
autoReLift: true, // default: true
|
|
88
|
+
deviceType: 'airpods', // 'watch' | 'airpods'
|
|
67
89
|
};
|
|
68
90
|
|
|
69
91
|
try {
|
|
70
92
|
const result = await SonarFitSDK.presentWorkout(config);
|
|
71
|
-
|
|
93
|
+
|
|
72
94
|
if (result.completed) {
|
|
73
95
|
console.log(`Completed ${result.totalRepsCompleted}/${result.totalTargetReps} reps`);
|
|
74
96
|
console.log(`Duration: ${result.totalDuration}s`);
|
|
@@ -111,7 +133,7 @@ interface WorkoutConfig {
|
|
|
111
133
|
restTime?: number; // default: 60
|
|
112
134
|
countdownDuration?: number; // default: 3
|
|
113
135
|
autoReLift?: boolean; // default: true
|
|
114
|
-
deviceType
|
|
136
|
+
deviceType: 'watch' | 'airpods';
|
|
115
137
|
}
|
|
116
138
|
|
|
117
139
|
interface WorkoutResult {
|
|
@@ -134,11 +156,38 @@ interface WorkoutResult {
|
|
|
134
156
|
}
|
|
135
157
|
```
|
|
136
158
|
|
|
159
|
+
## Debugging
|
|
160
|
+
|
|
161
|
+
### SDK Logging
|
|
162
|
+
|
|
163
|
+
The underlying iOS SDK supports multiple log levels for debugging. To enable logging, add this to your native iOS code (in `AppDelegate.swift` or similar):
|
|
164
|
+
|
|
165
|
+
```swift
|
|
166
|
+
import SonarFitKit
|
|
167
|
+
|
|
168
|
+
// In application(_:didFinishLaunchingWithOptions:)
|
|
169
|
+
#if DEBUG
|
|
170
|
+
SonarFitSDK.logLevel = .debug // See all logs during development
|
|
171
|
+
#else
|
|
172
|
+
SonarFitSDK.logLevel = .standard // Only errors and warnings in production
|
|
173
|
+
#endif
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Available log levels:
|
|
177
|
+
- `.none` - No logging
|
|
178
|
+
- `.minimal` - Only critical errors
|
|
179
|
+
- `.standard` - Errors and warnings (default)
|
|
180
|
+
- `.verbose` - Errors, warnings, and info messages
|
|
181
|
+
- `.debug` - All logs including motion processing and connectivity details
|
|
182
|
+
|
|
183
|
+
**Note:** Logging is controlled at the native iOS SDK level and cannot be changed from React Native JavaScript code.
|
|
184
|
+
|
|
137
185
|
## Requirements
|
|
138
186
|
|
|
139
187
|
- React Native >= 0.60
|
|
140
188
|
- iOS >= 17.0
|
|
141
|
-
- Xcode >=
|
|
189
|
+
- Xcode >= 16.0
|
|
190
|
+
- AirPods Pro/Max or Apple Watch (for motion tracking)
|
|
142
191
|
|
|
143
192
|
## Example
|
|
144
193
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonarfit-react-native",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "React Native integration for SonarFit SDK - AI-powered workout rep counting",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"react-native": "lib/index.js"
|
|
47
|
-
}
|
|
47
|
+
}
|