SDK Installation
Step-by-step guide to install the TakeProfit Widget SDK, covering prerequisites, installation commands, and initial setup. Follow this guide to ensure the SDK is correctly integrated into your project and ready for widget development on the TakeProfit platform.
Prerequisites
Before installing the TakeProfit Widget SDK, ensure that you meet the following requirements:
-
Package Manager: The SDK is distributed via npm, so you should have either npm (comes with Node.js) or yarn installed.
-
Project Setup: Ensure you have an existing project directory with a basic configuration, such as a
package.json
file. If not, you can create one with:
Install the SDK
The TakeProfit Widget SDK is available as an npm package. To install it, run the following command in your project directory:
If you prefer using yarn
, you can install it with:
This command will add the SDK as a dependency in your package.json
file and download it to the node_modules
directory.
Verifying Installation
After installation, you should see takeprofit-widget-sdk
listed under "dependencies"
in your package.json
file, like this:
Note: Replace ^0.2.3
with the version number you have installed.
Initialize the SDK in Your Project
Once installed, you can begin using the SDK by importing it into your project files. Here’s a simple setup example:
-
Import the SDK: Open the main file where you intend to initialize the SDK (e.g.,
index.js
,app.js
, ormain.ts
) and import the SDK: -
Basic Initialization: To ensure the SDK is correctly initialized, call the
connect
method when your widget is ready to communicate with the platform: -
Hiding the Loader: To let the TakeProfit platform know your widget is ready, use the
hideLoader
function after initialization:
This confirms that the SDK is successfully integrated and your widget can begin communicating with the platform.
Verify Installation
After setting up the SDK in your project, follow these steps to verify that it’s working correctly:
-
Test Initialization:
- Run your project (typically with
npm start
oryarn start
). - Check the browser’s developer console to ensure there are no errors related to
takeprofit-widget-sdk
.
- Run your project (typically with
-
Local Storage Configuration (for local widget testing):
-
Open Take Profit Platform in your browser.
-
Open your browser’s console and set up a local storage entry for your widget to test it on the TakeProfit platform interface.
-
Run this command in the browser console:
-
Replace
<your iframe URL>
and<icon URL>
with the actual URLs for testing. -
Reload the page and verify that your widget appears in the TakeProfit widget panel.
-
Common Issues & Troubleshooting
Here are some common issues you may encounter during installation, along with solutions:
By following this guide, you should now have the TakeProfit Widget SDK installed and ready for further customization and development.