GithubHelp home page GithubHelp logo

tiktok / tiktok-opensdk-ios Goto Github PK

View Code? Open in Web Editor NEW
65.0 65.0 18.0 1.17 MB

The TikTok OpenSDK features Login Kit and Share Kit which allow your users to log in using their TikTok account and share content from your app to TikTok.

Home Page: https://developers.tiktok.com

License: Other

Swift 97.06% Ruby 2.85% C 0.09%

tiktok-opensdk-ios's People

Contributors

guidopu avatar nickdnk avatar stephen-boyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiktok-opensdk-ios's Issues

tiktok share error,

shareState = Permission not granted

The demo provided has the same problem

why?

Importing into Objective-C++ / React Native project

Hi, we are developing a React Native application which should integrate with TikTok. Because it is a React Native app, it is made in Objective-C and not Swift. It is also a quite old application with many changes to the codebase, so refactoring AppDelegate into Swift is not an option.

Disclosure: I know next to nothing when it comes to iOS development, so the more information – the better.

From what I understood, Swift code (when made right, e.g. with @objc) can be imported into Objective-C code directly using a -Swift postfix. However, when I do #import <TikTokOpenSDKCore/TikTokOpenSDKCore-Swift.h> the compiler says there's no such file. I have tried plenty of different variants in different files and languages, same using "" instead of <>, also tried including using SPM instead of CocoaPods, but all to no avail.

During my research, I have found out that importable headers are located in /Pods/Headers/Public. I've inspected TikTokOpenSDKCore folder and the only header present there is TikTokOpenSDKCore-umbrella.h. But this header appears to be next to useless when it comes to importing actual classes and everything else. All it seems to do is import UIKit.h and export a couple of variables. Still, I have tried importing it instead of -Swift.h, of course it didn't work.

One thought was that some of other libraries or project settings interfere, so I have tried installing TikTok SDK on a brand new React Native project – nothing has changed. So I doubt it has something to do with my project specifically.

At this point, I have spent an obscene number of hours trying to make this work, and I feel like my head is going to explode. Have to admit, I am desperate for any help, so please forgive me for tagging @stephen-boyle @nickdnk.

My podfile has:

target 'myproject' do
  pod 'TikTokOpenSDKCore' // installs v2.2.0
  pod 'TikTokOpenAuthSDK' // installs v2.2.0

My AppDelegate.mm:

// AppDelegate.mm
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <Firebase.h>
#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>
#import "RNBootSplash.h"
#import "RNSplashScreen.h"
#import <TikTokOpenSDKCore/TikTokOpenSDKCore-Swift.h> // <- file not found

@implementation AppDelegate

// ...

// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  if ([TikTokURLHandler handleOpenURL:url]) { // <- Use of undeclared identifier 'TikTokURLHandler'
    return YES;
  }
  return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];

}

// ...

@end

Login Kit TikTokAuthRequest.send completion not call

I have implemented the TikTok login function according to the document, and have successfully activated TikTok authorization and return to our app. But it did not callback to the completion in TikTokAuthRequest.send. It only got the URL in func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool. What should I do to obtain a callback in TikTokAuthRequest.send‘s completion. Hope your answer.

how to add sdk in objective-C project?

my project is objective-C project,but sample codes is use swift. So i dont know how integerate it with objective-c. Please provide sample code with objective-c.Thanks

[Feature]: Support App Privacy Manifest

Aims
At WWDC23, Apple introduced a new Privacy Manifest and signatures for SDKs.
I would like to know when you plan to adopt these changes, considering Apple's deadline in Spring 2024.

References:

Could you please provide information on your adoption timeline for these updates? Thank you.

Description/Implementation Details

  • Add Privacy Manifest
  • Describing the use of required reason API

Shared images through TikTokShareRequest are in a wrong order

Hello there.

When I share multiple images through a TikTokShareRequest to have a carousel post on TikTok, the order of the images matching the supplied local asset identifiers is not kept.
From what I've seen so far, it seems that images in the final carousel are in the alphabetical order of their local asset identifiers.
For example, if I have this array of identifiers:

[
  "CB651F89-58DB-422D-8A55-CCCA3DA26310/L0/001", // Image 1
  "1C47D10E-4734-4B9F-A575-E40BC4AB3CB3/L0/001", // Image 2
  "26DBD447-6846-4CC7-AFEA-775DCE63EF90/L0/001" // Image 3
]

and pass it to a share request like so:

TikTokShareRequest(localIdentifiers: identifiers, mediaType: .image, redirectURI: <my_url>)

The images will appear inside the carousel in the TikTok app in this order:

[
  "1C47D10E-4734-4B9F-A575-E40BC4AB3CB3/L0/001", // Image 2
  "26DBD447-6846-4CC7-AFEA-775DCE63EF90/L0/001" // Image 3
  "CB651F89-58DB-422D-8A55-CCCA3DA26310/L0/001", // Image 1
]

The bug seems to be on TikTok app side, as the identifiers are still in the right order inside the deeplink launching it:

https://www.tiktok.com/opensdk/share/?request_id=EF[...]&media_paths=CB651F89-58DB-422D-8A55-CCCA3DA26310/L0/001,1C47D10E-4734-4B9F-A575-E40BC4AB3CB3/L0/001,26DBD447-6846-4CC7-AFEA-775DCE63EF90/L0/001&bundle_id=[...]

error_code=-4

When I use the sharing feature, I get the following error. Please help me resolve it. Thank you.

https://www.xxx.com/applinks/?from_platform=tiktoksharesdk&request_id=4517E659-083C-43AB-8F9A-DB63D09D6172&error_code=-4&error_description=Permissions%20denied&share_state=20003&response_id=A1013649-A297-4D14-8A7E-58EF29D7343C

When authorized to log in, opening my app using universal link failed, causing the app login to fail.

When authorized to log in, opening my app using universal link failed, causing the app login to fail.
A few users will encounter this situation. When installing the app for the first time, there may be a problem with the network connection, causing universal link related files to fail to download.I also encountered this problem when I installed the app after setting up a proxy on my iOS phone. Here's a video of the issue:

2023-11-29.14.20.27.mov

This web page address is the universal link I configured.
image

Pod file:
pod 'TikTokOpenSDKCore'
pod 'TikTokOpenAuthSDK'
sdk's version is 2.2.0

I found webpage information similar to this question:
https://stackoverflow.com/questions/65645013/ios-apple-universal-links-fails-randomly
https://stackoverflow.com/questions/44257362/ios-universal-links-sometimes-stops-working

When logging in, TikTok uses the universal link configuration to jump back to my app, but the download of the universal link description file may fail. The user must reinstall the app in a good network environment to use it normally. I would like to know if there is a better way to solve this problem besides reinstalling the app?

@stephen-boyle Could you help me look into this issue?

ShareKit - TikTok opens and closes immediately without sharing media

Hi, I am using TikTok's iOS SDK Share Kit to share my content from my app to TikTok. When I share a picture the application opens, showing a loading and immediately closing. I am not getting any response in return to identify the issue. This is the code I am using to share with TikTok. I have also attached a video to give you an idea about the issue.

TikTok.share.issue.mp4
let shareRequest = TikTokShareRequest(localIdentifiers: [videoFile!], mediaType: fileType == "image" ? .image : .video, redirectURI: redirectUrl!)
        shareRequest.shareFormat = .normal
        DispatchQueue.main.async {
            let returnResult = shareRequest.send { response in
                guard let shareResponse = response as? TikTokShareResponse else { return }
                    if shareResponse.errorCode == .noError {
                        print("Share succeeded!")
                        result("success")
                    } else {
                        print("Share Failed! Error Code: \(shareResponse.errorCode.rawValue) Error Message: \(shareResponse.errorDescription ?? "") Share State: \(shareResponse.shareState)")
                        result("error")
                    }
            }
            print("the result \(returnResult)")
        }

LoginKit isWebAuth = false, but always trying web auth and fail.

Hello, I'm flutter developer, I'm using android/ios loginkit via method channel.

It's my auth code.

 let scopes: Set = [
            "user.info.basic",
            "user.info.profile",
            "user.info.stats",
            "video.list"
        ]
        self.authRequest = TikTokAuthRequest(
            scopes: scopes,
            redirectURI: redirectUri
        )
        self.authRequest?.isWebAuth = false
        self.authRequest?.send { response in
            
            guard let authResponse = response as? TikTokAuthResponse else {
                result(FlutterError(
                    code: "temporarily_unavailable",
                    message: "Empty Response",
                    details: nil
                ))
                return
            }
            if authResponse.errorCode == .noError {
                let resultMap: Dictionary<String,String?> = [
                    "authCode": authResponse.authCode,
                    "state": authResponse.state,
                    "grantedPermissions": authResponse.grantedPermissions?.joined(separator: ","),
                    "codeVerifier": self.authRequest?.pkce.codeVerifier
                ]
                
                result(resultMap)
            } else {
                result(FlutterError(
                    code: String(authResponse.error ?? "-2"),
                    message: authResponse.errorDescription,
                    details: nil
                ))
            }
        }

my info plist

...

		<string>fbshareextension</string>
        <string>tiktokopensdk</string>
        <string>tiktoksharesdk</string>
        <string>snssdk1180</string>
        <string>snssdk1233</string>
	</array>


    <key>TikTokClientKey</key>
    <string>...</string>

	<key>CFBundleURLTypes</key>
	<array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>TikTok</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>...</string>
            </array>
        </dict>

authRequest?.isWebAuth = false

  1. but, my app trying always web auth when installed tiktok app or uninstalled tiktok app.
  2. and, web auth is fail and cannot go to redirect uri.

my tiktok app status is Live, and correct input redirect uri(it's universal url).
but I saw redirect fail message(formated json) on empty webpage like below:

{
    "data": {
        "captcha": "",
        "dest_url": "",
        "description": "Somwthing went wrong. Please try again",
        "error_code": 6,
    },
    "message": "error
}

I failed found that error_code 6 .

what's mean to error_code 6 ?

how can I modify myapp for isWebAuth = false working and redirect fail resolve?

please answer me.

thanks, best regard.

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false.

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false.

my tiktok sdk version is 2.2.0,

pod 'TikTokOpenSDKCore'
 pod 'TikTokOpenAuthSDK'

my code :

@objc
  public static func getAuthCode(scopes: NSString,resolver:@escaping RCTPromiseResolveBlock,rejecter:@escaping RCTPromiseRejectBlock)->Void{
    resolve = resolver;
    reject = rejecter;
    
    let scopesArray:Array = scopes.components(separatedBy: ",");
    var setScopes: Set<String> = [];
    let redirectUri = "https://m.iboominggxxx.xx/"
    let dict = NSMutableDictionary();
    var authRequest: TikTokAuthRequest?

    for index in 0 ..< scopesArray.count {
      setScopes.insert(scopesArray[index])
    }
    print("===getAuthCode 1111111==== ",setScopes);
    
    authRequest = TikTokAuthRequest(scopes: setScopes, redirectURI:redirectUri)
    authRequest?.isWebAuth = false
    
    DispatchQueue.main.sync {
      authRequest?.send { response in
        guard  let myresponse = response as? TikTokAuthResponse else {
          let errorObj = NSError(domain: "getAuthCode fail", code: -1);
          authRequest = nil
          reject?("getAuthCode fail","myresponse is null!",errorObj);
          return }

        if myresponse.errorCode != .noError {
          let message = "Error: \(myresponse.error ?? ""),code:\(String(myresponse.errorCode.rawValue)), Error Description: \(myresponse.errorDescription ?? "")"
          let errorObj = NSError(domain: message, code: myresponse.errorCode.rawValue);
            reject?("getAuthCode fail","errorCode is error! ",errorObj);
        }else{
          dict.setValue(myresponse.errorCode.rawValue, forKey:"errorCode")
          dict.setValue(myresponse.errorDescription, forKey:"errorMsg")
          dict.setValue(myresponse.authCode, forKey:"authCode")
          dict.setValue(scopes, forKey:"grantedPermissions")
          dict.setValue(authRequest?.pkce.codeVerifier, forKey:"codeVerifier")
          dict.setValue(redirectUri, forKey:"redirectUri")
          resolve?(dict)
          authRequest = nil
        }
        print("===getAuthCode 33333==== ", dict);
      }
    }
  }

//============= AppDelegate.m ===============
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url
                                 sourceApplication:sourceApplication annotation:annotation];
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{

  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
  return NO;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler{

   BOOL result = [TTKSDKURLHandler handleOpenURL:userActivity.webpageURL];
   NSLog(@"=========== restorationHandler  ========%@  result=%d",userActivity.webpageURL,result);
   if(result){
      return true;
   }

  return false;
}

isWebAuth is false, so user only open tiktok app to authorize.

So it is very strange why the user can jump to an external browser and open the tiktok authorization login on the webpage.
This is video record.

Lark20240328-163421.mp4

Hope help, thank you!

When jump to tiktok app for authorized login, it will show the error: "In order to protect our community, we restrict certain content on our platform."

On some ios devices, the following error will appear when you jump from the My app page to the tiktok app for authorized login:
image

This sentence means: "In order to protect our community, we restrict certain content on our platform."

"https://m.iboomingglobal.com/app/?code=xxxx" , it is my universal link.

So I don't know why some users have this problem with their mobile phones.If you konw,please tell me, Thanks.

404 Error when sharing asset from my app to TikTok with ShareKit

I'm encountering an issue using the ShareKit flow as described in the docs with TikTokShareRequest out of the TikTokOpenShareSDK library. All configuration steps have been triple-checked (TikTokClientKey in the appropriate places, URL schemes all setup per documentation, we've added LoginKit and ShareKit and submitted and approved our app on the TikTok developer portal).

I've verified that the asset exists and the localIdentifier is valid. I send this request to TikTok and the TikTok app launches an internal webview with a 404 page. There is no subsequent callback to my app and thus no information as to what part of the process failed.

This used to work with the legacy TikTokOpenSDK and TikTokOpenSDKShareRequest we used to use but I don't believe either SDK works anymore. The previous result would properly start a new video creation flow on the TikTok app side with the asset recorded in my app loaded up as the base. This is all we're trying to do here, but the SDK seems broken to me.

Unable to launch tiktok app when authorized to login in

The tiktok app cannot be launched when authorized to log in. A small number of users will encounter this situation. Below is the link address and video screenshot of the webpage:

https://www.tiktok.com/login?lang=en&enter_method=web&enter_from=dev_awro2yamp997e59t&redirect_url=https%253A%252F%252Fwww.tiktok.com%252Fv2%252Fauth%252Fauthorize%253Frequest_id%253D6A11683F-D1F8-4CD0-9D42-77F320C1EA34%2526api_version%253D2.2.0%2526consumer_key%253Dawro2yamp997e59t%2526app_identity%253Da44827d9e425a7b9f1965f1f4a59aa9bfdc1897e6ece0a9bc16b1ce5b5f35caf53f7e45c25b4008365d5dabd013d3673e9cc8c3a728c11082fe492b3c826021a%2526device_platform%253Diphone%2526state%2526permissions%253Duser.info.basic%252Cvideo.list%252Cuser.info.profile%252Cuser.info.stats%2526code_challenge%253Dc068ba6a5c1cb5a108d5b4644b14e76ecff382192e37137817d48a89c3170f04%2526redirect_uri%253Dhttps%253A%252F%252Fm.iboomingglobal.com%252Fapp%252F%2526sdk_name%253Dtiktok_sdk_auth%2526client_key%253Dawro2yamp997e59t%2526response_type%253Dcode%2526scope%253Duser.info.basic%252Cvideo.list%252Cuser.info.profile%252Cuser.info.stats%2526use_spark%253D1%2526hide_nav_bar%253D1&hide_left_icon=1&type=
Lark20231128-114924.mp4

Pod file:

pod 'TikTokOpenSDKCore'
 pod 'TikTokOpenAuthSDK'

sdk's version is 2.2.0

If you know the reason please tell me, thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.