@sency/react-native-smkit-ui 2.0.1 → 2.0.3

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 CHANGED
@@ -1,113 +1,138 @@
1
- # [Github:](https://github.com/sency-ai/smkit-sdk)
1
+ # React Native SMKit UI Library
2
2
 
3
- 1. [ Installation ](#inst)
4
- 2. [ Setup ](#setup)
5
- 3. [ API ](#api)
6
- 4. [ Data ](#data)
3
+ AI-powered fitness assessments, custom workouts, and workout programs with real-time motion detection for React Native apps.
7
4
 
8
- <a name="inst"></a>
5
+ ## Table of Contents
9
6
 
10
- ## 1. Installation
7
+ 1. [Features](#features)
8
+ 2. [Requirements](#requirements)
9
+ 3. [Installation](#installation)
10
+ 4. [Platform Setup](#platform-setup)
11
+ 5. [Getting Started](#getting-started)
12
+ 6. [Core Features](#core-features)
13
+ 7. [API Reference](#api-reference)
14
+ 8. [Examples](#examples)
15
+ 9. [Troubleshooting](#troubleshooting)
16
+ 10. [Support](#support)
11
17
 
12
- run `npm install @sency/react-native-smkit-ui`
18
+ ---
13
19
 
14
- ## 2. Setup <a name="setup"></a>
20
+ ## Features
15
21
 
16
- # iOS Setup
22
+ - **Fitness Assessments** - AI-driven fitness evaluations tailored to user fitness levels
23
+ - **Workout Programs** - Multi-week customizable workout plans with progression tracking
24
+ - **Motion Detection** - Real-time motion capture and analysis with pose detection
25
+ - **Multiple Assessment Types** - Fitness, Body360, Strength, Cardio, and custom assessments
26
+ - **Cross-Platform** - Native support for iOS and Android
27
+ - **Configurable Workouts** - Customize by body zone, difficulty, and duration
17
28
 
18
- 1. Update _Podfile_ in `iOS` folder:
29
+ ---
19
30
 
20
- ```
21
- [1] add the source to the top of your Podfile.
22
- source 'https://bitbucket.org/sencyai/ios_sdks_release.git'
23
- source 'https://github.com/CocoaPods/Specs.git'
31
+ ## Requirements
24
32
 
25
- [2] add use_frameworks! commend to your target
26
- target 'YOUR_TARGET' do
27
- use_frameworks!
33
+ ### General
34
+ - **Node.js** 18+
35
+ - **npm** or **yarn**
28
36
 
29
- [3] At the end of your code please add
30
-
31
- post_install do |installer|
32
- react_native_post_install(
33
- installer,
34
- :mac_catalyst_enabled => false
35
- )
36
- installer.pods_project.targets.each do |target|
37
- target.build_configurations.each do |config|
38
- config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
39
- config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
40
- end
41
- end
42
- __apply_Xcode_12_5_M1_post_install_workaround(installer)
43
- end
44
- end
37
+ ### iOS
38
+ - **iOS 13+**
39
+ - **Xcode 14+**
40
+ - **CocoaPods**
41
+
42
+ ### Android
43
+ - **Android API 26+**
44
+ - **Android Studio** with SDK tools
45
+ - **JDK 11+**
46
+
47
+ ---
48
+
49
+ ## Installation
45
50
 
51
+ Install the package via npm:
52
+
53
+ ```bash
54
+ npm install @sency/react-native-smkit-ui
46
55
  ```
47
56
 
48
- 2. Run `NO_FLIPPER=1 pod install` to install the necessary pods.
49
- 3. Add camera permission request to `Info.plist`
57
+ Or with yarn:
50
58
 
51
- ```Xml
52
- <key>NSCameraUsageDescription</key>
53
- <string>Camera access is needed</string>
59
+ ```bash
60
+ yarn add @sency/react-native-smkit-ui
61
+ ```
62
+
63
+ Then install native dependencies:
64
+
65
+ ```bash
66
+ cd ios && pod install && cd ..
54
67
  ```
55
68
 
56
69
  ---
57
70
 
58
- ## Known issues
71
+ ## Platform Setup
72
+
73
+ ### iOS Setup
59
74
 
60
- 1. Dynamic/Static linking issues due to `use_frameworks`:
61
- If you're unable to use use_frameworks you should add the following code to your Podfile:
75
+ 1. Add the required CocoaPods sources to your `ios/Podfile`:
62
76
 
63
77
  ```ruby
64
- # [1] Add the dynamic_frameworks array that will hold all of the dynamic frameworks names
65
- dynamic_frameworks = ['SMKitUI', 'SMKit', 'SMBase', 'SwiftyJSON', 'SMBaseUI']
66
-
67
- # [2] Add this pre_install function
68
- pre_install do |installer|
69
- installer.pod_targets.each do |pod|
70
- if dynamic_frameworks.include?(pod.name)
71
- def pod.build_type
72
- Pod::BuildType.dynamic_framework
73
- end
74
- end
75
- end
78
+ source 'https://bitbucket.org/sencyai/ios_sdks_release.git'
79
+ source 'https://github.com/CocoaPods/Specs.git'
80
+ ```
81
+
82
+ 2. Add `use_frameworks!` to your target:
83
+
84
+ ```ruby
85
+ target 'YourApp' do
86
+ use_frameworks!
87
+ # ... other pods
76
88
  end
89
+ ```
90
+
91
+ 3. Add the post-install hook at the end of your Podfile:
77
92
 
78
- # [3] Add this post_install function
93
+ ```ruby
79
94
  post_install do |installer|
80
- react_native_post_install(installer, config[:reactNativePath], :mac_catalyst_enabled => false)
81
- installer.pods_project.targets.each do |target|
82
- if dynamic_frameworks.include?(target.name)
83
- target.build_configurations.each do |config|
84
- config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
85
- config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
86
- end
87
- end
95
+ react_native_post_install(
96
+ installer,
97
+ :mac_catalyst_enabled => false
98
+ )
99
+ installer.pods_project.targets.each do |target|
100
+ target.build_configurations.each do |config|
101
+ config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
102
+ config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
88
103
  end
89
104
  end
105
+ __apply_Xcode_12_5_M1_post_install_workaround(installer)
90
106
  end
91
107
  ```
92
108
 
93
- Now you can run pod install.
109
+ 4. Install pods:
110
+
111
+ ```bash
112
+ cd ios
113
+ NO_FLIPPER=1 pod install
114
+ cd ..
115
+ ```
116
+
117
+ 5. Add camera permission to `Info.plist`:
94
118
 
95
- # Android Setup
119
+ ```xml
120
+ <key>NSCameraUsageDescription</key>
121
+ <string>Camera access is needed for fitness assessments and motion detection</string>
122
+ ```
96
123
 
97
- In order to integrate SMKitUI you need your app to target minSdk 26
98
- Add on project level `build.gradle`:
124
+ ### Android Setup
99
125
 
100
- ```groovy
126
+ 1. Update your project-level `build.gradle`:
127
+
128
+ ```gradle
101
129
  buildscript {
102
130
  ext {
103
131
  minSdkVersion = 26
132
+ // ... other settings
104
133
  }
105
134
  }
106
- ```
107
-
108
- Add on project level build.gradle:
109
135
 
110
- ```groovy
111
136
  allprojects {
112
137
  maven {
113
138
  url "https://artifacts.sency.ai/artifactory/release/"
@@ -115,558 +140,376 @@ allprojects {
115
140
  }
116
141
  ```
117
142
 
118
- ## 3. API<a name="api"></a>
119
-
120
- ### 1. Configure <a name="conf"></a>
143
+ 2. Ensure your app's `build.gradle` targets Android API 26+:
121
144
 
122
- ```js
123
- [1] First import configure
124
- import { configure } from '@sency/react-native-smkit-ui/src/index.tsx';
125
-
126
- [2] then call the configure function with your auth key
127
- try{
128
- var res = await configure("YOUR_AUTH_KEY");
129
- }catch (e) {
130
- console.error(e);
145
+ ```gradle
146
+ android {
147
+ compileSdkVersion 35
148
+ defaultConfig {
149
+ minSdkVersion 26
150
+ targetSdkVersion 35
151
+ }
131
152
  }
132
153
  ```
133
154
 
134
- To reduce wait time we recommend to call `configure` on app launch.
135
-
136
- **⚠️ smkit_ui_library will not work if you don't first call configure.**
137
-
138
- ## 2. Start <a name="start"></a>
139
-
140
- #### [Start Assessment](#data)
141
-
142
- - [Start Assessment](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/Assessment.md)
143
-
144
- - [Start Workout](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/Workout.md)
145
-
146
- - [Build Your Own Assessment](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/CustomizedAssessment.md)
147
-
148
- ##Data <a name="data"></a>
149
-
150
- ### AssessmentTypes
151
-
152
- | Name (enum) | Description | More info |
153
- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
154
- | Fitness | For individuals of any activity level who seek to enhance their physical abilities, strength, and endurance through a tailored plan. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/AI-Fitness-Assessment.md) |
155
- | Body360 | Designed for individuals of any age and activity level, this assessment determines the need for a preventative plan or medical support. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/360-Body-Assessment.md) |
156
- | Strength | For individuals of any activity level who seek to assess their strength capabilities (core and endurance) \* This assessment will be available soon. Contact us for more info. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/Strength.md) |
157
- | Cardio | For individuals of any activity level who seek to assess their cardiovascular capabilities \* This assessment will be available soon. Contact us for more info. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/Cardio.md) |
158
- | Custom | If Sency created a tailored assessment for you, you probably know it, and you should use this enum. | |
159
-
160
- Having issues? [Contact us](mailto:support@sency.ai) and let us know what the problem is.
161
-
162
- # React Native SMKit UI Library
163
-
164
- This is a React Native plugin that implements the SMKit UI native library for both iOS and Android platforms. The library provides fitness assessments, custom workouts, and workout programs with motion detection capabilities.
165
-
166
- ## Prerequisites
167
-
168
- Before running the example app, ensure you have the following installed:
169
-
170
- ### General Requirements
171
- - **Node.js** (version 18 or higher)
172
- - **Yarn** package manager
173
- - **React Native CLI**
174
-
175
- ### iOS Development
176
- - **Xcode** (latest version)
177
- - **CocoaPods**
178
- - **iOS Simulator** or physical iOS device
155
+ ---
179
156
 
180
- ### Android Development
181
- - **Android Studio** with Android SDK
182
- - **Java Development Kit (JDK)** 11 or higher
183
- - **Android Virtual Device (AVD)** or physical Android device
157
+ ## Getting Started
184
158
 
185
- ## Quick Setup Guide
159
+ ### 1. Initialize the Library
186
160
 
187
- ### 1. Install Dependencies
161
+ Call `configure()` as early as possible in your app (e.g., on app launch):
188
162
 
189
- First, install Yarn globally if you haven't already:
190
- ```bash
191
- npm install -g yarn
192
- ```
163
+ ```typescript
164
+ import { configure } from '@sency/react-native-smkit-ui';
193
165
 
194
- Install React Native CLI:
195
- ```bash
196
- npm install -g @react-native-community/cli
166
+ try {
167
+ await configure('YOUR_API_KEY');
168
+ } catch (error) {
169
+ console.error('Failed to configure SMKit UI:', error);
170
+ }
197
171
  ```
198
172
 
199
- ### 2. Clone and Setup Project
200
-
201
- ```bash
202
- # Navigate to the project root
203
- cd /path/to/react-native-smkit-ui
204
-
205
- # Install root dependencies
206
- yarn install
207
-
208
- # Build the library
209
- yarn build
210
- ```
173
+ > **⚠️ Important:** The library will not function until `configure()` is called successfully.
211
174
 
212
- ### 3. Setup Example App
175
+ ### 2. Request Camera Permissions
213
176
 
214
- ```bash
215
- # Create the library package
216
- npm pack
177
+ Ensure your app has camera permissions granted before starting assessments or workouts:
217
178
 
218
- # Navigate to example directory
219
- cd example
179
+ ```typescript
180
+ import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
220
181
 
221
- # Update package.json to use the generated tarball
222
- # The tarball will be named something like: sency-react-native-smkit-ui-1.3.2.tgz
223
- ```
182
+ const cameraPermission = await request(
183
+ Platform.OS === 'ios'
184
+ ? PERMISSIONS.IOS.CAMERA
185
+ : PERMISSIONS.ANDROID.CAMERA
186
+ );
224
187
 
225
- Update `example/package.json` dependencies:
226
- ```json
227
- {
228
- "dependencies": {
229
- "@sency/react-native-smkit-ui": "file:../sency-react-native-smkit-ui-1.3.2.tgz",
230
- // ... other dependencies
231
- }
188
+ if (cameraPermission === RESULTS.GRANTED) {
189
+ // Ready to start assessments/workouts
232
190
  }
233
191
  ```
234
192
 
235
- ```bash
236
- # Install example dependencies
237
- yarn install
238
- ```
193
+ ---
239
194
 
240
- ## Running on iOS
195
+ ## Core Features
241
196
 
242
- ### 1. Install iOS Dependencies
243
- ```bash
244
- cd example/ios
245
- pod install
246
- cd ..
247
- ```
197
+ ### Assessment Types
248
198
 
249
- ### 2. Start Metro Bundler
250
- ```bash
251
- yarn start
252
- ```
199
+ | Type | Purpose | Use Case |
200
+ |------|---------|----------|
201
+ | **Fitness** | Comprehensive fitness evaluation | General fitness assessment for all levels |
202
+ | **Body360** | Full-body movement and posture analysis | Preventative health screening |
203
+ | **Strength** | Core and endurance strength testing | Evaluate strength capabilities |
204
+ | **Cardio** | Cardiovascular capacity assessment | Assess aerobic fitness |
205
+ | **Custom** | Custom assessment (provided by Sency) | Specialized evaluations |
253
206
 
254
- ### 3. Run iOS App
255
- In a new terminal:
256
- ```bash
257
- cd example
258
- yarn ios
259
- ```
207
+ ### Workout Configuration
260
208
 
261
- Or to run on a specific simulator:
262
- ```bash
263
- yarn ios --simulator="iPhone 15"
264
- ```
209
+ Customize workouts with:
210
+ - **Body Zones**: Full Body, Upper Body, Lower Body, Core
211
+ - **Difficulty**: Low, Medium, High
212
+ - **Duration**: Short, Medium, Long
213
+ - **Week Number**: For multi-week programs
265
214
 
266
- ## Running on Android
215
+ ---
267
216
 
268
- ### 1. Setup Android Environment
217
+ ## API Reference
269
218
 
270
- Make sure you have:
271
- - Android Studio installed with Android SDK
272
- - Android Virtual Device (AVD) created and running, OR
273
- - Physical Android device connected with USB debugging enabled
219
+ ### Core Methods
274
220
 
275
- Check your setup:
276
- ```bash
277
- npx react-native doctor
278
- ```
221
+ #### `configure(apiKey: string): Promise<void>`
279
222
 
280
- ### 2. Configure Gradle Memory
223
+ Initialize the SMKit UI library with your API key.
281
224
 
282
- The `example/android/gradle.properties` file should include:
283
- ```properties
284
- org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
285
- org.gradle.parallel=true
286
- android.useAndroidX=true
287
- android.enableJetifier=true
288
- hermesEnabled=true
289
- ```
225
+ ```typescript
226
+ import { configure } from '@sency/react-native-smkit-ui';
290
227
 
291
- ### 3. Start Metro Bundler
292
- ```bash
293
- cd example
294
- yarn start
228
+ await configure('YOUR_API_KEY');
295
229
  ```
296
230
 
297
- ### 4. Run Android App
298
- In a new terminal:
299
- ```bash
300
- cd example
301
- yarn android
302
- ```
303
-
304
- ## Troubleshooting
305
-
306
- ### Metro Port Already in Use
307
- If you get "EADDRINUSE: address already in use :::8081":
308
- ```bash
309
- # Kill existing Metro process
310
- lsof -ti:8081 | xargs kill -9
231
+ ---
311
232
 
312
- # Then restart
313
- yarn start --reset-cache
314
- ```
233
+ #### `startAssessment(type: AssessmentType, options?: AssessmentOptions): Promise<AssessmentResult>`
315
234
 
316
- ### Android Build Issues
235
+ Start a fitness assessment.
317
236
 
318
- #### Java Heap Space Error
319
- If you get "Java heap space" error:
320
- ```bash
321
- # Clean build cache
322
- cd example/android
323
- ./gradlew clean
324
- cd ..
325
-
326
- # Clear Gradle cache
327
- rm -rf ~/.gradle/caches/
237
+ ```typescript
238
+ import { startAssessment, AssessmentType } from '@sency/react-native-smkit-ui';
328
239
 
329
- # Try building with specific architecture
330
- yarn android --variant=debug --architectures=arm64-v8a
240
+ const result = await startAssessment(AssessmentType.Fitness, {
241
+ showSummary: true,
242
+ customId: 'user-123'
243
+ });
331
244
  ```
332
245
 
333
- #### Dependency Resolution Issues
334
- ```bash
335
- # Clear all caches and reinstall
336
- cd example
337
- rm -rf node_modules
338
- yarn install
339
-
340
- # Reset Metro cache
341
- yarn start --reset-cache
342
- ```
246
+ **Parameters:**
247
+ - `type` - The assessment type (Fitness, Body360, Strength, Cardio, Custom)
248
+ - `options` - Optional configuration object
249
+ - `showSummary` - Display summary after completion (default: true)
250
+ - `customId` - Custom identifier for the assessment
343
251
 
344
- ### iOS Build Issues
252
+ ---
345
253
 
346
- #### Pod Installation Problems
347
- ```bash
348
- cd example/ios
349
- rm -rf Pods
350
- rm Podfile.lock
351
- pod cache clean --all
352
- pod install
353
- cd ..
354
- ```
254
+ #### `startWorkoutProgram(config: WorkoutConfig): Promise<WorkoutResult>`
355
255
 
356
- #### Xcode Build Errors
357
- - Open `example/ios/SmkitUiLibraryExample.xcworkspace` in Xcode
358
- - Clean Build Folder (⌘ + Shift + K)
359
- - Build the project (⌘ + B)
360
-
361
- ## Example App Features
362
-
363
- The example app demonstrates the following SMKit UI library features:
364
-
365
- ### Fitness Assessments
366
- - **Basic Assessment**: Standard fitness evaluation
367
- - **Body360 Assessment**: Comprehensive body analysis
368
- - **Custom Assessments**: Configurable assessment types
369
-
370
- ### Workouts
371
- - **Custom Workouts**: Create personalized exercise routines
372
- - **Workout Programs**: Multi-week fitness programs
373
- - **Exercise Types**: Squats, push-ups, lunges, planks, and more
374
-
375
- ### Configuration Options
376
- - Body zones (Full Body, Upper Body, Lower Body, Core)
377
- - Difficulty levels (Low, Medium, High)
378
- - Duration settings (Short, Medium, Long)
379
- - Motion detection capabilities
380
-
381
- ## Development Workflow
382
-
383
- ### Making Changes to the Library
384
-
385
- 1. Make your changes in the `src/` directory
386
- 2. Build the library:
387
- ```bash
388
- yarn build
389
- ```
390
- 3. Create new package:
391
- ```bash
392
- npm pack
393
- ```
394
- 4. Update example app dependency and reinstall:
395
- ```bash
396
- cd example
397
- yarn install
398
- ```
399
- 5. Test your changes:
400
- ```bash
401
- yarn ios # or yarn android
402
- ```
403
-
404
- ### Testing on Physical Devices
405
-
406
- #### iOS
407
- - Connect your iOS device
408
- - Ensure it's registered in your Apple Developer account
409
- - Run: `yarn ios --device`
410
-
411
- #### Android
412
- - Enable Developer Options and USB Debugging on your device
413
- - Connect via USB
414
- - Verify connection: `adb devices`
415
- - Run: `yarn android`
416
-
417
- ## API Usage
418
-
419
- The example app in `example/src/App.tsx` shows how to use the main library functions:
256
+ Start a workout program with customization options.
420
257
 
421
258
  ```typescript
422
- import { configure, startAssessment, startCustomAssessment, startWorkoutProgram } from '@sency/react-native-smkit-ui';
423
-
424
- // Configure the library
425
- await configure(apiKey, userId);
426
-
427
- // Start an assessment
428
- await startAssessment(assessmentType, showSummary, customId);
429
-
430
- // Start a workout program
431
- const config = new WorkoutConfig(week, bodyZone, difficulty, duration, programId);
432
- await startWorkoutProgram(config);
433
- ```
434
-
435
- ## Updating Native Dependencies
259
+ import { startWorkoutProgram, WorkoutConfig, BodyZone, Difficulty, Duration } from '@sency/react-native-smkit-ui';
436
260
 
437
- If you update the native SMKit UI library version (e.g., from `smkitui:1.3.6` to `smkitui:1.3.7`):
261
+ const config = new WorkoutConfig(
262
+ week: 1,
263
+ bodyZone: BodyZone.FullBody,
264
+ difficulty: Difficulty.Medium,
265
+ duration: Duration.Medium,
266
+ programId: 'program-123'
267
+ );
438
268
 
439
- ### 1. Update Plugin Dependencies
440
-
441
- Update the version in the plugin's `android/build.gradle`:
442
- ```gradle
443
- dependencies {
444
- implementation 'com.sency.smkitui:smkitui:1.3.7' // Updated version
445
- // ...other dependencies
446
- }
269
+ const result = await startWorkoutProgram(config);
447
270
  ```
448
271
 
449
- ### 2. Rebuild Plugin Package
450
-
451
- ```bash
452
- # From plugin root directory
453
- npm pack
454
- ```
455
-
456
- ### 3. Update Example App
457
-
458
- ```bash
459
- cd example
460
-
461
- # Clean and reinstall dependencies
462
- rm -rf node_modules
463
- yarn install
272
+ ---
464
273
 
465
- # Clean Android build cache
466
- cd android
467
- ./gradlew clean --refresh-dependencies
468
- cd ..
274
+ #### `startCustomAssessment(config: CustomAssessmentConfig): Promise<AssessmentResult>`
469
275
 
470
- # Clear React Native cache and rebuild
471
- yarn start --reset-cache &
472
- yarn android
473
- ```
276
+ Start a custom assessment (assessment configured by Sency for your specific needs).
474
277
 
475
- ### 4. Verify Native Dependency Update
278
+ ```typescript
279
+ import { startCustomAssessment } from '@sency/react-native-smkit-ui';
476
280
 
477
- ```bash
478
- cd example/android
479
- ./gradlew app:dependencies | grep smkitui
480
- # Should show: com.sency.smkitui:smkitui:1.3.7
281
+ const result = await startCustomAssessment({
282
+ customId: 'assessment-123',
283
+ showSummary: true
284
+ });
481
285
  ```
482
286
 
483
- ### 5. Troubleshoot Missing Dependencies
484
-
485
- If you get "Could not read script" errors:
486
-
487
- #### For react-native-config Issues:
488
- ```bash
489
- cd example
287
+ ---
490
288
 
491
- # Reinstall react-native-config
492
- yarn remove react-native-config
493
- yarn add react-native-config
289
+ ## Examples
494
290
 
495
- # If still missing, temporarily comment out in app/build.gradle:
496
- # // apply from: "../../node_modules/react-native-config/android/dotenv.gradle"
291
+ ### Complete Setup Example
497
292
 
498
- # Use hardcoded API key temporarily in App.tsx for testing
293
+ ```typescript
294
+ import React, { useEffect, useState } from 'react';
295
+ import { View, TouchableOpacity, Text } from 'react-native';
296
+ import {
297
+ configure,
298
+ startAssessment,
299
+ startWorkoutProgram,
300
+ AssessmentType,
301
+ BodyZone,
302
+ Difficulty,
303
+ Duration,
304
+ WorkoutConfig
305
+ } from '@sency/react-native-smkit-ui';
306
+
307
+ export default function FitnessApp() {
308
+ const [isConfigured, setIsConfigured] = useState(false);
309
+
310
+ useEffect(() => {
311
+ initializeApp();
312
+ }, []);
313
+
314
+ const initializeApp = async () => {
315
+ try {
316
+ await configure('YOUR_API_KEY');
317
+ setIsConfigured(true);
318
+ } catch (error) {
319
+ console.error('Configuration failed:', error);
320
+ }
321
+ };
322
+
323
+ const handleFitnessAssessment = async () => {
324
+ try {
325
+ const result = await startAssessment(AssessmentType.Fitness, {
326
+ showSummary: true
327
+ });
328
+ console.log('Assessment completed:', result);
329
+ } catch (error) {
330
+ console.error('Assessment failed:', error);
331
+ }
332
+ };
333
+
334
+ const handleWorkout = async () => {
335
+ try {
336
+ const config = new WorkoutConfig(
337
+ 1,
338
+ BodyZone.FullBody,
339
+ Difficulty.Medium,
340
+ Duration.Medium
341
+ );
342
+ const result = await startWorkoutProgram(config);
343
+ console.log('Workout completed:', result);
344
+ } catch (error) {
345
+ console.error('Workout failed:', error);
346
+ }
347
+ };
348
+
349
+ return (
350
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
351
+ <TouchableOpacity
352
+ onPress={handleFitnessAssessment}
353
+ disabled={!isConfigured}
354
+ >
355
+ <Text>Start Fitness Assessment</Text>
356
+ </TouchableOpacity>
357
+
358
+ <TouchableOpacity
359
+ onPress={handleWorkout}
360
+ disabled={!isConfigured}
361
+ >
362
+ <Text>Start Workout</Text>
363
+ </TouchableOpacity>
364
+ </View>
365
+ );
366
+ }
499
367
  ```
500
368
 
501
- #### Force Clean All Caches:
502
- ```bash
503
- # Clean gradle caches
504
- rm -rf ~/.gradle/caches/modules-2/files-2.1/com.sency.smkitui/
369
+ ### Body360 Assessment Example
505
370
 
506
- # Clean project
507
- cd example/android
508
- ./gradlew clean --refresh-dependencies
509
- cd ..
510
-
511
- # Clean React Native
512
- yarn start --reset-cache
371
+ ```typescript
372
+ const startBody360Assessment = async () => {
373
+ try {
374
+ const result = await startAssessment(AssessmentType.Body360, {
375
+ showSummary: true,
376
+ customId: `user-${Date.now()}`
377
+ });
378
+
379
+ if (result.success) {
380
+ console.log('Body360 assessment completed');
381
+ console.log('Results:', result.data);
382
+ }
383
+ } catch (error) {
384
+ console.error('Body360 assessment error:', error);
385
+ }
386
+ };
513
387
  ```
514
388
 
515
- ## Android 15 Support
516
-
517
- The example app supports Android 15 (API level 35) with the following configuration:
389
+ ### Customized Workout Example
518
390
 
519
- ### Requirements
520
- - compileSdkVersion = 35
521
- - targetSdkVersion = 35
522
- - Android Studio with Android 15 SDK
523
- - Gradle 8.4+
524
-
525
- ### Configuration
526
- The project is already configured for Android 15 in `example/android/build.gradle`:
527
- ```gradle
528
- buildscript {
529
- ext {
530
- compileSdkVersion = 35
531
- targetSdkVersion = 35
532
- kotlinVersion = "1.9.10"
533
- }
534
- }
391
+ ```typescript
392
+ const startCustomizedWorkout = async () => {
393
+ try {
394
+ const config = new WorkoutConfig(
395
+ week: 2,
396
+ bodyZone: BodyZone.UpperBody,
397
+ difficulty: Difficulty.High,
398
+ duration: Duration.Long
399
+ );
400
+
401
+ const result = await startWorkoutProgram(config);
402
+ console.log('Workout program completed:', result);
403
+ } catch (error) {
404
+ console.error('Workout error:', error);
405
+ }
406
+ };
535
407
  ```
536
408
 
537
- ### Testing on Android 15
538
- 1. Create an Android 15 emulator in Android Studio
539
- 2. Ensure camera permissions are granted
540
- 3. Monitor for privacy-related warnings in logcat
409
+ ---
541
410
 
542
- ## Environment Variables
411
+ ## Troubleshooting
543
412
 
544
- The example app uses environment variables to manage the SMKit API key securely:
413
+ ### "Configuration Failed" Error
545
414
 
546
- ### Setup
547
- 1. Copy `.env.example` to `.env` in the `example` directory
548
- 2. Add your API key: `SMKIT_API_KEY=your_actual_key`
549
- 3. The `.env` file is automatically ignored by git
415
+ **Problem:** `configure()` throws an error or returns false.
550
416
 
551
- ### Usage
552
- ```typescript
553
- import Config from 'react-native-config';
417
+ **Solutions:**
418
+ - Verify your API key is correct
419
+ - Check your internet connection
420
+ - Ensure the SMKit backend service is available
421
+ - Call `configure()` before using any other library functions
554
422
 
555
- const apiKey = Config.SMKIT_API_KEY;
556
- await configure(apiKey);
557
- ```
423
+ ### Camera Permissions Not Granted
558
424
 
559
- ### Troubleshooting Environment Variables
560
- If you get "Missing API Key" errors:
561
- 1. Verify `.env` file exists in `example/` directory
562
- 2. Check `SMKIT_API_KEY` is set correctly
563
- 3. Clean and rebuild: `yarn start --reset-cache`
564
- 4. For testing, you can temporarily use a hardcoded key
425
+ **Problem:** Assessment or workout fails with camera permission error.
565
426
 
566
- ## Publishing the Package
427
+ **Solutions:**
428
+ - Request camera permissions before starting assessments
429
+ - Check that permissions are granted in device settings
430
+ - On iOS, verify `NSCameraUsageDescription` is in `Info.plist`
431
+ - On Android, ensure runtime permissions are requested
567
432
 
568
- ### Automated Publishing with Script
433
+ ### iOS Pod Installation Issues
569
434
 
570
- The project includes an automated publish script that handles the entire release process:
435
+ **Problem:** `pod install` fails or shows version conflicts.
571
436
 
437
+ **Solutions:**
572
438
  ```bash
573
- # Run the interactive publish script
574
- npm run publish-package
575
-
576
- # Or run directly
577
- ./scripts/publish.sh
439
+ cd ios
440
+ rm -rf Pods
441
+ rm Podfile.lock
442
+ pod cache clean --all
443
+ pod install
444
+ cd ..
578
445
  ```
579
446
 
580
- #### Publish Script Features
581
-
582
- The publish script (`scripts/publish.sh`) provides:
583
-
584
- - ✅ **Git Status Check** - Warns about uncommitted changes
585
- - ✅ **Version Management** - Interactive version selection (patch/minor/major/custom)
586
- - ✅ **Build Verification** - Cleans and builds with Bob
587
- - ✅ **Testing Support** - Creates test package for example app validation
588
- - ✅ **NPM Authentication** - Checks login status and prompts if needed
589
- - ✅ **Dry Run** - Shows package contents before publishing
590
- - ✅ **Safety Confirmations** - Multiple confirmation steps
591
- - ✅ **Automated Publishing** - Publishes to NPM with proper access
592
- - ✅ **Changelog Reminder** - Prompts to update CHANGELOG.md with release notes
593
- - ✅ **Git Tagging** - Creates and pushes release tags automatically
594
- - ✅ **Verification** - Confirms package availability on NPM
447
+ ### Android Build Failures
595
448
 
596
- #### Quick Commands
449
+ **Problem:** Gradle build fails with native dependency errors.
597
450
 
451
+ **Solutions:**
598
452
  ```bash
599
- # Check current versions across all files
600
- npm run version-check
453
+ # Clean Gradle caches
454
+ rm -rf ~/.gradle/caches/
601
455
 
602
- # Create a test package for local testing
603
- npm run test-package
456
+ # Clean project
457
+ cd android
458
+ ./gradlew clean
459
+ cd ..
604
460
 
605
- # Full publish process
606
- npm run publish-package
461
+ # Rebuild
462
+ npm install
463
+ yarn android
607
464
  ```
608
465
 
609
- #### Manual Publishing Steps
466
+ ### Motion Detection Not Working
610
467
 
611
- If you prefer manual control:
468
+ **Problem:** Assessment starts but motion detection fails.
612
469
 
613
- ```bash
614
- # 1. Update version
615
- npm version patch # or minor/major
616
-
617
- # 2. Build the library
618
- npm run clean
619
- npx bob build
470
+ **Solutions:**
471
+ - Ensure adequate lighting in the environment
472
+ - Position user fully in camera frame
473
+ - Verify camera lens is clean
474
+ - Check that device camera is not in use by another app
620
475
 
621
- # 3. Test with example app
622
- npm pack
623
- # Update example/package.json to use the .tgz file
624
- # Test the example app
476
+ ### Library Not Initializing
625
477
 
626
- # 4. Publish to NPM
627
- npm login
628
- npm publish --access public
478
+ **Problem:** Features don't work even after calling `configure()`.
629
479
 
630
- # 5. Create git tag
631
- git tag v1.3.2
632
- git push origin v1.3.2
633
- ```
480
+ **Solutions:**
481
+ - Verify `configure()` was called and completed successfully
482
+ - Check for error messages in console logs
483
+ - Ensure you're not calling library methods before `configure()` completes
484
+ - Test with a fresh app start
634
485
 
635
- #### Pre-Publishing Checklist
636
-
637
- Before publishing, ensure:
638
-
639
- - ✅ Native dependencies are updated (e.g., `smkitui:1.3.7`)
640
- - ✅ Version numbers are consistent across all files
641
- - ✅ CHANGELOG.md is updated with release notes
642
- - ✅ Library builds successfully with `npx bob build`
643
- - ✅ Example app works with the new build
644
- - ✅ All changes are committed to git
645
- - ✅ You have NPM publish permissions for `@sency/react-native-smkit-ui`
486
+ ---
646
487
 
647
- ## 📚 Documentation
488
+ ## Additional Resources
648
489
 
649
- - **[API Reference](API.md)** - Complete API documentation with examples
490
+ - **[API Documentation](API.md)** - Complete API reference with detailed parameters
650
491
  - **[Changelog](CHANGELOG.md)** - Version history and release notes
651
- - **[Example App](example/)** - Working example implementation
492
+ - **[Example App](example/)** - Working demonstration app with source code
652
493
 
653
- ## 📦 Package Information
654
-
655
- Visit our [NPM page](https://www.npmjs.com/package/@sency/react-native-smkit-ui) for:
656
- - Latest version information
657
- - Download statistics
658
- - Dependency information
659
- - Version history
494
+ ---
660
495
 
661
496
  ## Support
662
497
 
663
- For issues and questions:
664
- 1. Check the troubleshooting sections above
665
- 2. Run `npx react-native doctor` to verify your environment
666
- 3. Check the example app implementation in `example/src/App.tsx`
667
- 4. Review the native iOS and Android implementations in the respective platform folders
668
- 5. Consult the [API Reference](API.md) for detailed function documentation
498
+ Need help?
499
+
500
+ - **Documentation**: See [API.md](API.md) for detailed API documentation
501
+ - **Issues**: Check our [GitHub Issues](https://github.com/sency-ai/smkit-sdk/issues)
502
+ - **Email**: [support@sency.ai](mailto:support@sency.ai)
503
+
504
+ ---
669
505
 
670
506
  ## License
671
507
 
672
508
  MIT
509
+
510
+ ---
511
+
512
+ ## Repository
513
+
514
+ - **GitHub**: [sency-ai/smkit-sdk](https://github.com/sency-ai/smkit-sdk)
515
+ - **NPM Package**: [@sency/react-native-smkit-ui](https://www.npmjs.com/package/@sency/react-native-smkit-ui)