npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@raiden16f7/react-native-tiktok-business-sdk

v1.1.3

Published

A React Native bridge for the TikTok Business SDK

Readme

react-native-tiktok-business-sdk

npm version Build Status npm downloads License

A React Native bridge for the TikTok Business SDK

This library exposes native methods for initializing the TikTok SDK, identifying users, logging out, and tracking various events (standard, content, and custom events) via the TikTok Business SDK.

Installation

Install the package using npm (or yarn):

npm install react-native-tiktok-business-sdk

yarn add react-native-tiktok-business-sdk

Usage

Below are examples of how to use the various methods exposed by the library.

Importing the Library

The package exposes a main object, TikTokBusiness, that aggregates all the methods and enums. For example:

import { TikTokBusiness } from 'react-native-tiktok-business-sdk';

Initialize the SDK

Before using any event tracking methods, you must initialize the SDK. You can call initializeSdk with your appId and tiktokAppId, and optionally set debug mode. (The debug parameter defaults to false if not provided).

async function initializeTikTokSDK() {
  try {
    await TikTokBusiness.initializeSdk(
      'YOUR_APP_ID',
      'YOUR_TIKTOK_APP_ID',
      true
    );
    // SDK is now initialized, and tracking is active.
  } catch (error) {
    console.error('Error initializing TikTok SDK:', error);
  }
}

initializeTikTokSDK();

Identify a User

Call the identify method to report user information.

async function identifyUser() {
  try {
    await TikTokBusiness.identify(
      'externalId',
      'externalUserName',
      'phoneNumber',
      '[email protected]'
    );
  } catch (error) {
    console.error('Error identifying user:', error);
  }
}

Logout

Log out the user with the logout method:

async function logoutUser() {
  try {
    await TikTokBusiness.logout();
  } catch (error) {
    console.error('Error logging out:', error);
  }
}

Track a Standard Event

Use trackEvent to report standard events. You can optionally pass an event ID and additional properties. For example, to track a "REGISTRATION" event:

async function trackStandardEvent() {
  try {
    await TikTokBusiness.trackEvent(TikTokEventName.REGISTRATION);
  } catch (error) {
    console.error('Error tracking standard event:', error);
  }
}

Track a Content Event

For events that require content details (e.g., “ADD_TO_CART”, “CHECK_OUT”, etc.), use trackContentEvent. The method accepts an event type string and a parameters object. The CONTENTS property should be an array of objects with keys defined in the TikTokContentParameter enum.

TikTokBusiness.trackContentEvent(TikTokContentEventName.CHECK_OUT, {
  [TikTokContentEventParameter.CURRENCY]: 'USD',
  [TikTokContentEventParameter.VALUE]: '4.99',
  [TikTokContentEventParameter.CONTENT_TYPE]: 'Purchase',
  [TikTokContentEventParameter.CONTENTS]: [
    {
      [TikTokContentEventContentsParameter.CONTENT_ID]: 'ABC',
      [TikTokContentEventContentsParameter.CONTENT_NAME]: 'Coffee',
      [TikTokContentEventContentsParameter.PRICE]: '4.99',
      [TikTokContentEventContentsParameter.QUANTITY]: 1,
    },
  ],
});

Track a Custom Event

If you need to report an event that isn’t standard, use trackCustomEvent and pass the event name and a properties object.

async function trackCustomEvent() {
  try {
    await TikTokBusiness.trackCustomEvent('custom_event_name', {
      description: 'This is a custom event',
      value: 200,
      currency: 'USD',
    });
  } catch (error) {
    console.error('Error tracking custom event:', error);
  }
}

Enums

The library exports the following enums to ensure consistency when reporting events:

  • TikTokEventName – Standard event names.
  • TikTokContentEventName – Content event names.
  • TikTokContentEventParameter – Parameters for content events.
  • TikTokContentEventContentsParameter – Parameters for the contents parameter of content events.

Example:

import {
  TikTokBusiness,
  TikTokContentEventContentsParameter,
  TikTokEventName,
  TikTokContentEventParameter,
  TikTokContentEventName,
} from 'react-native-tiktok-business-sdk';

Proguard

If you're using Proguard to optimize your app, you must add rules to prevent Proguard from removing classes.

-keep class com.tiktok.** { *; }
-keep class com.android.billingclient.api.** { *; }

Upcoming Features

  • [ ] Add example app
  • [ ] Unit and integration tests
  • [ ] Add support for TurboModules
  • [ ] Improve TypeScript declarations and documentation
  • [ ] Enhance error handling and logging mechanisms
  • [ ] Support additional TikTok Business SDK events

Contributing

See the contributing guide to learn how to contribute to the repository and our development workflow.

License

MIT