This documentation is intended to guide React Native developers through the process of integrating and utilizing the TrainingSDK in their projects.
To integrate the TrainingSDK in your React Native project using Swift Package Manager, follow these steps:
-
Open your project in Xcode: First, ensure your React Native project is open in Xcode.
-
Adding Swift Package:
- Go to
File
->Swift Packages
->Add Package Dependency
. - Enter the URL for the TrainingSDK:
https://github.com/miguelmunozfer/TrainingSDKSPM
- Follow the prompts to choose the version and options for integrating the package into your project.
- Go to
-
Verifying Integration:
- Once added, ensure that the TrainingSDK package appears in the Swift Package Dependencies section of your project.
- You can now use the SDK as per the documentation provided.
This process will integrate the TrainingSDK into your React Native project, allowing you to utilize its functionalities through Swift and bridging to React Native.
Before starting, ensure that your React Native project is set up and ready to integrate native modules.
- Place the
TrainingSDKBridge.swift
andTrainingSDKBridge.m
along with any other required Swift files in your project's directory.
- If you haven't already, create a bridging header to use Swift with Objective-C in your project. This is usually done automatically by Xcode when you add a new Swift file to an Objective-C project.
- Add
#import "React/RCTBridgeModule.h"
to the bridging header.
After successfully integrating the SDK, you can use the provided methods in your React Native JavaScript code. Here’s a brief overview of the available methods:
Starts the TrainingSDK session with the given user credentials.
user
: String - The user identifier.appID
: String - The application ID.password
: String - The password.
import { TrainingSDKBridge } from 'NativeModules';
TrainingSDKBridge.start('username', 'appId', 'password');
Updates the user's profile with the provided details.
sex
: String (optional) - The user's gender. The possible options are:Male
for maleFemale
for female
height
: Number (optional) - The user's height in centimeters.weight
: Number (optional) - The user's weight in kilograms.birthDateString
: String (optional) - The user's birth date in 'yyyy-MM-dd' format.
TrainingSDKBridge.updateProfile('Male', 180, 75, '1990-01-01');
Displays the nutrition module.
TrainingSDKBridge.showTrainingModule();
Logs out the current user from the SDK.
TrainingSDKBridge.logout();
Sets the main color theme for the SDK's UI elements.
color
: String - The color in a string format (e.g., hex code).
TrainingSDKBridge.setMainColor('FF5733'); // Example with a hex color code
Sets the navigation bar color.
color
: String - The color in a string format.
TrainingSDKBridge.setNavigationBarColor('007AFF');
Sets the navigation tint color, which is often used for button items in the navigation bar.
color
: String - The color in a string format.
TrainingSDKBridge.setNavigationTintColor('FFFFFF');
Sets the title for the navigation bar.
title
: String - The title text.
- Ensure that the data types passed from JavaScript match the expected types in Swift.
- Some functions might require additional handling based on the NutritionIASDK's requirements and capabilities.
This documentation provides a basic outline for using the TrainingSDK in a React Native environment. Developers may need to adjust usage and implementation details based on their specific project needs and the SDK's capabilities.