@makewaves/tiktok-sdk
by makewaves | v1.0.10
Add a plugin description
npm i --save @makewaves/tiktok-sdk

@makewaves/tiktok-sdk

A nativescript plugin that allows you to authenticate users with TikTok Open SDK, including LoginKit.

Installation

Add the plugin

Add the plugin to your project using the command:

npm install @makewaves/tiktok-sdk

Setup Swift Package Manager

Add the Swift Package Manager block to your project's nativescript.config.ts file.

ios: {
SPMPackages: [
{
name: "TikTokOpenSDK",
libs: ["TikTokOpenAuthSDK", "TikTokOpenSDKCore", "TikTokOpenShareSDK"],
repositoryURL: "https://github.com/tiktok/tiktok-opensdk-ios.git",
version: "2.2.0"
}
]
}

Run the initialisation on app startup

To hook up the AppDelegate functions on iOS, the initialisation needs to run during the starup of the application.

To do this, add the following line to your app.ts/app.js entrypoint file:

TikTok.setup(Application);

For example:

import { Application } from '@nativescript/core';
import { TikTok } from '@makewaves/tiktok-sdk';

TikTok.setup(Application);

Application.run({ moduleName: 'app-root' });

For more information about this step, please read the TikTok Mobile SDK Quickstart Guide.

Configuration

  1. Go to TikTok Developer Portal and sign up for a developer account on the TikTok for Developers website.

  2. Create a new app, add the required details, and submit it for review. This will provide you with a client key and client secret that is unique to your app which will be used for the next steps.

Configuring iOS

In order to run the TikTok Mobile SDK on an iOS device, you will need a working universal link configuration, and a provisioning profile with the Associated Domains capability. Import your provisioning profile, update the bundle ID, and add your universal link domain to the Associated Domains section. Make sure you have added your universal link to the Redirect URI portion of the Login Kit section in the developer portal.

For more information about Universal Links in NativeScript, see here.


Once you have configured the Universal Links for iOS, add the following block to your App_Resources/iOS/Info.plist file and modify the following key-value pairs depending on your requirements:

  • Add the following values to LSApplicationQueriesSchemes:

    • tiktokopensdk for Login Kit.
    • tiktoksharesdk for Share Kit.
    • snssdk1233 and snssdk1180 to check if TikTok is installed on your device.
  • Add TikTokClientKey key with your app's client key, obtained from the TikTok for Developers website, as the value. Add your app's client key to CFBundleURLSchemes.

<key>LSApplicationQueriesSchemes</key>
<array>
<string>tiktokopensdk</string>
<string>tiktoksharesdk</string>
<string>snssdk1180</string>
<string>snssdk1233</string>
</array>

<key>TikTokClientKey</key>
<string>$TikTokClientKey</string>

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>$TikTokClientKey</string>
</array>
</dict>
</array>

Remember to replace $TikTokClientKey with your actual key.

Configuring Android

Register your app on the TikTok for Developers website. You must provide your MD5 and SHA256 certificate fingerprint during the app registration process.

If your app uses app signing by Google Play, copy the MD5 and SHA-256 fingerprint from the app signing page of the Play Console.

If your app is using self-signing, you can follow the instructions below to use Keytool to get your MD5 and SHA-256.

Using Keytool, Open a terminal and run the keytool utility to get the MD5 and SHA-256 fingerprint of the certificate.

keytool -list -v \
-alias <your-key-name> -keystore <path-to-production-keystore>

MD5: 75:C8:69:FC:D5:6E:EB:1D:02:79:A9:3F:91:BD:5E:5B
SHA1: EE:26:47:EC:59:83:6A:91:3C:7A:E1:61:14:56:6D:D8:90:B7:BA:3E
SHA-256: 6C:CF:15:C0:17:2E:EF:3E:48:2F:7E:E8:ED:6D:06:CB:CB:52:A4:CF:AD:CE:42:0B:80:9D:D5:D9:DE:DA:4C:7D

Provide the MD5 and SHA-256 for your app on the TikTok for Developers website.

  • In the App signature field, remove the colon from your MD5 string and provide the 32-character signature.
  • In the Signing certificate fingerprints field, provide your SHA-256 string directly.

Due to changes in Android 11 regarding package visibility, you will also need to add the following to the Android Manifest file in your project.

<queries>
<package android:name="com.zhiliaoapp.musically" />
<package android:name="com.ss.android.ugc.trill" />
</queries>

Usage

// TODO

License

Apache License Version 2.0