TikTok Open Platform SDK for iOS - Quickstart

Integrating our open SDK can help you leverage TikTok's open platform capabilities, such as sharing videos and pictures directly into TikTok. We hope to help you enhance your app's discovery and engagement, as well as provide another location for your users to share their favorite content for the world to see.

Getting Started with the TikTok SDK for iOS

Requirements

TikTok iOS SDK requires iOS 9.3 and Xcode 4.5 or later.

Step 1: Configure TikTok App Settings for iOS

Go to TikTok Developer App Registration Page to create your app. After approval, you will get the Client Key.

Step 2: Install the SDK

Via Cocoapods (Recommend)

Add the pod to your Podfile:

pod 'TikTokOpenSDK', '~> 3.0.2'

And then run:

pod install --repo-update

Via Manual Install

Download TikTokOpenSDK and Download BytedanceOpenPlatformSDK, unzip the zip files, and you would find the SDKs called TikTokOpenSDK.framework and BytedanceOpenPlatformSDK.framework.

Link Framework

  1. Copy or Drag the SDKs into your Xcode Project. Select your Project in Project Navigator. Click "+" in TARGETS -> Build Phases -> Link Binary With Libraries, and then select TikTokOpenSDK.framework in your Project folder to add it.

  2. Add WebKit.framework and Security.framework.

  • WebKit.framework - It is used to gain authorization through web-view when TikTok is not installed.
  • Security.framework - Encryption and decryption library. We use this framework to ensure that communications are securely transmitted.
  1. Add Link Flag -ObjC in TARGETS->Build Settings->Other Linker Flags. Make sure the letter 'O' and 'C' are capitalized.

The correct configuration is shown below: 1_1_1

Step 3: Configure Xcode Project

Configure Info.plist

  1. In Xcode, right-click your project's Info.plist file and select Open As -> Source Code.
  2. Here are 3 keys need to configuration:
    1. LSApplicationQueriesSchemes: Use to Open TikTop App
    2. TikTokAppID: Use to config TikTok OpenSDK
    3. CFBundleURLTypes : Use TikTok App callback your App Insert the following XML snippet into the body of your file just before the final </dict> element.
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>tiktoksharesdk</string>
    <string>snssdk1180</string>
    <string>snssdk1233</string>
</array>
<key>TikTokAppID</key>
<string>$TikTokAppID</string>
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>$TikTokAppID</string>
    </array>
  </dict>
</array>
  1. Replace $TikTokAppID with your App's Client Key

Note:

  • tiktoksharesdk is used for sharing.
  • snssdk1233, snssdk1180 are used to check if the TikTok application is installed.
  • The TikTok Open SDK auto-registers your Client Key when your App launches.

Make sure your app has access to Photo Library

Sharing pictures requires Photo Library access. Make sure a proper Privacy - Photo Library Usage Description is added in your Info.plist.

After the configuration, your Info.plist will look like the following. 1_3

Step 4: Connect App delegate

Connect App delegate You need to connect your AppDelegate class to the TikTokOpenSDKApplicationDelegate.h To do this, add the following code to your AppDelegate.m file.

#import <TikTokOpenSDK/TikTokOpenSDKApplicationDelegate.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[TikTokOpenSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
        return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    
    if ([[TikTokOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]
        ) {
        return YES;
    }    
    return NO;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if ([[TikTokOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) {
        return YES;
    }
    return NO;
}
    
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if ([[TikTokOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:nil annotation:nil]) {
        return YES;
    }
    return NO;
}
@end

API Instructions

TikTokOpenSDKApplicationDelegate

Log Delegate

@protocol BDOpenPlatformLogDelegate <NSObject>

- (void)onLog:(NSString *)logInfo;

@end

TikTok internal log in level ERROR or Warning will callback in this method.You need to register log delgate in TikTokOpenSDKApplicationDelegate

Usage :

    [TikTokOpenSDKApplicationDelegate sharedInstance].logDelegate = self; 

Check TikTok is installed :

- (BOOL)isAppInstalled;

BDOpenPlatformObjects

The definition of basic classes (Reuqest or Response) to SDK.