包详细信息

@sency/react-native-smkit-ui

sency-ai1.2kMIT2.0.3

React Native library for SMKit UI - Advanced fitness assessments and workout programs with AI-powered motion detection and real-time performance tracking

react-native, fitness, assessment, workout

自述文件

React Native SMKit UI Library

AI-powered fitness assessments, custom workouts, and workout programs with real-time motion detection for React Native apps.

Table of Contents

  1. Features
  2. Requirements
  3. Installation
  4. Platform Setup
  5. Getting Started
  6. Core Features
  7. API Reference
  8. Examples
  9. Troubleshooting
  10. Support

Features

  • Fitness Assessments - AI-driven fitness evaluations tailored to user fitness levels
  • Workout Programs - Multi-week customizable workout plans with progression tracking
  • Motion Detection - Real-time motion capture and analysis with pose detection
  • Multiple Assessment Types - Fitness, Body360, Strength, Cardio, and custom assessments
  • Cross-Platform - Native support for iOS and Android
  • Configurable Workouts - Customize by body zone, difficulty, and duration

Requirements

General

  • Node.js 18+
  • npm or yarn

iOS

  • iOS 13+
  • Xcode 14+
  • CocoaPods

Android

  • Android API 26+
  • Android Studio with SDK tools
  • JDK 11+

Installation

Install the package via npm:

npm install @sency/react-native-smkit-ui

Or with yarn:

yarn add @sency/react-native-smkit-ui

Then install native dependencies:

cd ios && pod install && cd ..

Platform Setup

iOS Setup

  1. Add the required CocoaPods sources to your ios/Podfile:
source 'https://bitbucket.org/sencyai/ios_sdks_release.git'
source 'https://github.com/CocoaPods/Specs.git'
  1. Add use_frameworks! to your target:
target 'YourApp' do
  use_frameworks!
  # ... other pods
end
  1. Add the post-install hook at the end of your Podfile:
post_install do |installer|
  react_native_post_install(
    installer,
    :mac_catalyst_enabled => false
  )
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
    end
  end
  __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
  1. Install pods:
cd ios
NO_FLIPPER=1 pod install
cd ..
  1. Add camera permission to Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is needed for fitness assessments and motion detection</string>

Android Setup

  1. Update your project-level build.gradle:
buildscript {
    ext {
        minSdkVersion = 26
        // ... other settings
    }
}

allprojects {
    maven {
        url "https://artifacts.sency.ai/artifactory/release/"
    }
}
  1. Ensure your app's build.gradle targets Android API 26+:
android {
    compileSdkVersion 35
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 35
    }
}

Getting Started

1. Initialize the Library

Call configure() as early as possible in your app (e.g., on app launch):

import { configure } from '@sency/react-native-smkit-ui';

try {
  await configure('YOUR_API_KEY');
} catch (error) {
  console.error('Failed to configure SMKit UI:', error);
}

⚠️ Important: The library will not function until configure() is called successfully.

2. Request Camera Permissions

Ensure your app has camera permissions granted before starting assessments or workouts:

import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';

const cameraPermission = await request(
  Platform.OS === 'ios' 
    ? PERMISSIONS.IOS.CAMERA 
    : PERMISSIONS.ANDROID.CAMERA
);

if (cameraPermission === RESULTS.GRANTED) {
  // Ready to start assessments/workouts
}

Core Features

Assessment Types

Type Purpose Use Case
Fitness Comprehensive fitness evaluation General fitness assessment for all levels
Body360 Full-body movement and posture analysis Preventative health screening
Strength Core and endurance strength testing Evaluate strength capabilities
Cardio Cardiovascular capacity assessment Assess aerobic fitness
Custom Custom assessment (provided by Sency) Specialized evaluations

Workout Configuration

Customize workouts with:

  • Body Zones: Full Body, Upper Body, Lower Body, Core
  • Difficulty: Low, Medium, High
  • Duration: Short, Medium, Long
  • Week Number: For multi-week programs

API Reference

Core Methods

configure(apiKey: string): Promise<void>

Initialize the SMKit UI library with your API key.

import { configure } from '@sency/react-native-smkit-ui';

await configure('YOUR_API_KEY');

startAssessment(type: AssessmentType, options?: AssessmentOptions): Promise<AssessmentResult>

Start a fitness assessment.

import { startAssessment, AssessmentType } from '@sency/react-native-smkit-ui';

const result = await startAssessment(AssessmentType.Fitness, {
  showSummary: true,
  customId: 'user-123'
});

Parameters:

  • type - The assessment type (Fitness, Body360, Strength, Cardio, Custom)
  • options - Optional configuration object
    • showSummary - Display summary after completion (default: true)
    • customId - Custom identifier for the assessment

startWorkoutProgram(config: WorkoutConfig): Promise<WorkoutResult>

Start a workout program with customization options.

import { startWorkoutProgram, WorkoutConfig, BodyZone, Difficulty, Duration } from '@sency/react-native-smkit-ui';

const config = new WorkoutConfig(
  week: 1,
  bodyZone: BodyZone.FullBody,
  difficulty: Difficulty.Medium,
  duration: Duration.Medium,
  programId: 'program-123'
);

const result = await startWorkoutProgram(config);

startCustomAssessment(config: CustomAssessmentConfig): Promise<AssessmentResult>

Start a custom assessment (assessment configured by Sency for your specific needs).

import { startCustomAssessment } from '@sency/react-native-smkit-ui';

const result = await startCustomAssessment({
  customId: 'assessment-123',
  showSummary: true
});

Examples

Complete Setup Example

import React, { useEffect, useState } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import {
  configure,
  startAssessment,
  startWorkoutProgram,
  AssessmentType,
  BodyZone,
  Difficulty,
  Duration,
  WorkoutConfig
} from '@sency/react-native-smkit-ui';

export default function FitnessApp() {
  const [isConfigured, setIsConfigured] = useState(false);

  useEffect(() => {
    initializeApp();
  }, []);

  const initializeApp = async () => {
    try {
      await configure('YOUR_API_KEY');
      setIsConfigured(true);
    } catch (error) {
      console.error('Configuration failed:', error);
    }
  };

  const handleFitnessAssessment = async () => {
    try {
      const result = await startAssessment(AssessmentType.Fitness, {
        showSummary: true
      });
      console.log('Assessment completed:', result);
    } catch (error) {
      console.error('Assessment failed:', error);
    }
  };

  const handleWorkout = async () => {
    try {
      const config = new WorkoutConfig(
        1,
        BodyZone.FullBody,
        Difficulty.Medium,
        Duration.Medium
      );
      const result = await startWorkoutProgram(config);
      console.log('Workout completed:', result);
    } catch (error) {
      console.error('Workout failed:', error);
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <TouchableOpacity
        onPress={handleFitnessAssessment}
        disabled={!isConfigured}
      >
        <Text>Start Fitness Assessment</Text>
      </TouchableOpacity>

      <TouchableOpacity
        onPress={handleWorkout}
        disabled={!isConfigured}
      >
        <Text>Start Workout</Text>
      </TouchableOpacity>
    </View>
  );
}

Body360 Assessment Example

const startBody360Assessment = async () => {
  try {
    const result = await startAssessment(AssessmentType.Body360, {
      showSummary: true,
      customId: `user-${Date.now()}`
    });

    if (result.success) {
      console.log('Body360 assessment completed');
      console.log('Results:', result.data);
    }
  } catch (error) {
    console.error('Body360 assessment error:', error);
  }
};

Customized Workout Example

const startCustomizedWorkout = async () => {
  try {
    const config = new WorkoutConfig(
      week: 2,
      bodyZone: BodyZone.UpperBody,
      difficulty: Difficulty.High,
      duration: Duration.Long
    );

    const result = await startWorkoutProgram(config);
    console.log('Workout program completed:', result);
  } catch (error) {
    console.error('Workout error:', error);
  }
};

Troubleshooting

"Configuration Failed" Error

Problem: configure() throws an error or returns false.

Solutions:

  • Verify your API key is correct
  • Check your internet connection
  • Ensure the SMKit backend service is available
  • Call configure() before using any other library functions

Camera Permissions Not Granted

Problem: Assessment or workout fails with camera permission error.

Solutions:

  • Request camera permissions before starting assessments
  • Check that permissions are granted in device settings
  • On iOS, verify NSCameraUsageDescription is in Info.plist
  • On Android, ensure runtime permissions are requested

iOS Pod Installation Issues

Problem: pod install fails or shows version conflicts.

Solutions:

cd ios
rm -rf Pods
rm Podfile.lock
pod cache clean --all
pod install
cd ..

Android Build Failures

Problem: Gradle build fails with native dependency errors.

Solutions:

# Clean Gradle caches
rm -rf ~/.gradle/caches/

# Clean project
cd android
./gradlew clean
cd ..

# Rebuild
npm install
yarn android

Motion Detection Not Working

Problem: Assessment starts but motion detection fails.

Solutions:

  • Ensure adequate lighting in the environment
  • Position user fully in camera frame
  • Verify camera lens is clean
  • Check that device camera is not in use by another app

Library Not Initializing

Problem: Features don't work even after calling configure().

Solutions:

  • Verify configure() was called and completed successfully
  • Check for error messages in console logs
  • Ensure you're not calling library methods before configure() completes
  • Test with a fresh app start

Additional Resources


Support

Need help?


License

MIT


Repository