diff --git a/tiktok/NuGet.Config b/tiktok/NuGet.Config new file mode 100644 index 0000000..f24ae56 --- /dev/null +++ b/tiktok/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/tiktok/README.md b/tiktok/README.md new file mode 100644 index 0000000..51cf15c --- /dev/null +++ b/tiktok/README.md @@ -0,0 +1,45 @@ +# TikTok App Events Slim Binding +This folder contains a slim binding which demonstrations using [TikTok App Events][0] + +## Setup +The TikTok Business sdk must be added to the root of the sample folder. The SDK is distributed via [Jitpack][3], [download the aar][4]. Next the App IDs and Tik Tok App IDs must be set in app.xaml.cs. +* The App IDs come from the respective app stores +* See [Generating TikTok App IDs][2] + +## Manually Building The Android Binding +These steps may or may not be required based on your machine's configuration. + +```shell +cd tiktok/android/native +./gradlew build +cd ../TikTok.Android.Binding +dotnet build -t:InstallAndroidDependencies -f net9.0-android +``` + +### Build and Run +```shell + dotnet build sample -t:Run -f net9.0-android + dotnet build sample -t:Run -f net9.0-ios +``` + +## Notes +* If you experience issues with missing references manually invoking gradlew build before building the dotnet project helps. +* NativeLibraryInterop depends on "CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks", this package is not yet on Nuget, when migrating this sample into your project be sure to include the NuGet.Config in your project's folder. +* You will also need to add the following to your project's csproj +``` + + + Always + + + + + + +``` + +[0]: https://business-api.tiktok.com/portal/docs?id=1739584951798785 +[1]: https://jitpack.io/com/github/tiktok/tiktok-business-android-sdk/1.3.8/tiktok-business-android-sdk-1.3.8.aar +[2]: https://business-api.tiktok.com/portal/docs?id=1739584951798785#item-link-Generate%20your%20TikTok%20App%20ID +[3]: https://jitpack.io/com/github/tiktok/tiktok-business-android-sdk/1.3.8/ +[4]: https://jitpack.io/com/github/tiktok/tiktok-business-android-sdk/1.3.8/tiktok-business-android-sdk-1.3.8.aar \ No newline at end of file diff --git a/tiktok/android/TikTok.Android.Binding/Additions/AboutAdditions.txt b/tiktok/android/TikTok.Android.Binding/Additions/AboutAdditions.txt new file mode 100644 index 0000000..2775bd3 --- /dev/null +++ b/tiktok/android/TikTok.Android.Binding/Additions/AboutAdditions.txt @@ -0,0 +1,48 @@ +Additions allow you to add arbitrary C# to the generated classes +before they are compiled. This can be helpful for providing convenience +methods or adding pure C# classes. + +== Adding Methods to Generated Classes == + +Let's say the library being bound has a Rectangle class with a constructor +that takes an x and y position, and a width and length size. It will look like +this: + +public partial class Rectangle +{ + public Rectangle (int x, int y, int width, int height) + { + // JNI bindings + } +} + +Imagine we want to add a constructor to this class that takes a Point and +Size structure instead of 4 ints. We can add a new file called Rectangle.cs +with a partial class containing our new method: + +public partial class Rectangle +{ + public Rectangle (Point location, Size size) : + this (location.X, location.Y, size.Width, size.Height) + { + } +} + +At compile time, the additions class will be added to the generated class +and the final assembly will a Rectangle class with both constructors. + + +== Adding C# Classes == + +Another thing that can be done is adding fully C# managed classes to the +generated library. In the above example, let's assume that there isn't a +Point class available in Java or our library. The one we create doesn't need +to interact with Java, so we'll create it like a normal class in C#. + +By adding a Point.cs file with this class, it will end up in the binding library: + +public class Point +{ + public int X { get; set; } + public int Y { get; set; } +} \ No newline at end of file diff --git a/tiktok/android/TikTok.Android.Binding/TikTok.Android.Binding.csproj b/tiktok/android/TikTok.Android.Binding/TikTok.Android.Binding.csproj new file mode 100644 index 0000000..13ae246 --- /dev/null +++ b/tiktok/android/TikTok.Android.Binding/TikTok.Android.Binding.csproj @@ -0,0 +1,30 @@ + + + net9.0-android + 21 + enable + enable + + true + MauiTikTokAndroid.Android.Binding + + + + + + + MauiTikTok + + + + + diff --git a/tiktok/android/TikTok.Android.Binding/Transforms/EnumFields.xml b/tiktok/android/TikTok.Android.Binding/Transforms/EnumFields.xml new file mode 100644 index 0000000..2295995 --- /dev/null +++ b/tiktok/android/TikTok.Android.Binding/Transforms/EnumFields.xml @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/tiktok/android/TikTok.Android.Binding/Transforms/EnumMethods.xml b/tiktok/android/TikTok.Android.Binding/Transforms/EnumMethods.xml new file mode 100644 index 0000000..49216c6 --- /dev/null +++ b/tiktok/android/TikTok.Android.Binding/Transforms/EnumMethods.xml @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/tiktok/android/TikTok.Android.Binding/Transforms/Metadata.xml b/tiktok/android/TikTok.Android.Binding/Transforms/Metadata.xml new file mode 100644 index 0000000..8e3e4b0 --- /dev/null +++ b/tiktok/android/TikTok.Android.Binding/Transforms/Metadata.xml @@ -0,0 +1,4 @@ + + + MauiTikTokAndroid + diff --git a/tiktok/android/native/.gitignore b/tiktok/android/native/.gitignore new file mode 100644 index 0000000..37c59e8 --- /dev/null +++ b/tiktok/android/native/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +*/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/tiktok/android/native/build.gradle.kts b/tiktok/android/native/build.gradle.kts new file mode 100644 index 0000000..18f1856 --- /dev/null +++ b/tiktok/android/native/build.gradle.kts @@ -0,0 +1,6 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id("com.android.library") version "8.6.1" apply false +} + + diff --git a/tiktok/android/native/gradle.properties b/tiktok/android/native/gradle.properties new file mode 100644 index 0000000..a03b354 --- /dev/null +++ b/tiktok/android/native/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true diff --git a/tiktok/android/native/gradle/wrapper/gradle-wrapper.jar b/tiktok/android/native/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/tiktok/android/native/gradle/wrapper/gradle-wrapper.jar differ diff --git a/tiktok/android/native/gradle/wrapper/gradle-wrapper.properties b/tiktok/android/native/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ab0c921 --- /dev/null +++ b/tiktok/android/native/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Jun 24 14:49:07 EDT 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/tiktok/android/native/gradlew b/tiktok/android/native/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/tiktok/android/native/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/tiktok/android/native/gradlew.bat b/tiktok/android/native/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/tiktok/android/native/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/tiktok/android/native/mauitiktok/build.gradle.kts b/tiktok/android/native/mauitiktok/build.gradle.kts new file mode 100644 index 0000000..c714212 --- /dev/null +++ b/tiktok/android/native/mauitiktok/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + id("com.android.library") +} + +android { + namespace = "com.microsoft.tiktok" + compileSdk = 34 + + defaultConfig { + minSdk = 21 + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +dependencies { + //... other dependencies + implementation("com.github.tiktok:tiktok-business-android-sdk:1.3.8"); + //to listen for app life cycle + implementation("androidx.lifecycle:lifecycle-process:2.3.1"); + implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1"); + //to get Google install referrer + implementation("com.android.installreferrer:installreferrer:2.2"); +} diff --git a/tiktok/android/native/mauitiktok/proguard-rules.pro b/tiktok/android/native/mauitiktok/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/tiktok/android/native/mauitiktok/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/tiktok/android/native/mauitiktok/src/main/AndroidManifest.xml b/tiktok/android/native/mauitiktok/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9ddf586 --- /dev/null +++ b/tiktok/android/native/mauitiktok/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/tiktok/android/native/mauitiktok/src/main/java/com/example/newbinding/DotnetTikTokBinding.java b/tiktok/android/native/mauitiktok/src/main/java/com/example/newbinding/DotnetTikTokBinding.java new file mode 100644 index 0000000..ffa28e8 --- /dev/null +++ b/tiktok/android/native/mauitiktok/src/main/java/com/example/newbinding/DotnetTikTokBinding.java @@ -0,0 +1,78 @@ +package com.microsoft.tiktok; + +import com.tiktok.TikTokBusinessSdk; +import com.tiktok.TikTokBusinessSdk.TTConfig; +import com.tiktok.appevents.*; +import com.tiktok.appevents.base.EventName; +import com.tiktok.appevents.base.TTBaseEvent; + +import android.content.Context; + +public class DotnetTikTokBinding +{ + public static String getString(String myString) + { + return myString + " from java!"; + } + + public static void InitTikTok(String appId, String tikTokAppId, Context appContext, boolean isDebug) + { + // Set AppId & TikTok App ID in application code + TTConfig ttConfig = new TTConfig(appContext) //(getApplicationContext()) + .setAppId(appId) // Android package name or iOS listing ID, eg: com.sample.app (from Play Store) or 9876543 (from App Store) + .setTTAppId(tikTokAppId); // TikTok App ID from TikTok Events Manager + + if(isDebug) + { + ttConfig = ttConfig + .openDebugMode() + .setLogLevel(TikTokBusinessSdk.LogLevel.DEBUG); + } + TikTokBusinessSdk.initializeSdk(ttConfig); + //If you need to listener the initialization status, please use the initialization function with callback + TikTokBusinessSdk.initializeSdk(ttConfig, new TikTokBusinessSdk.TTInitCallback() { + @Override + public void success() { + //Initialization successful + System.out.print("Tiktok init success"); + } + + @Override + public void fail(int code, String msg) { + //initialization failed + System.out.print("Tiktok init failed"); + } + }); + // TikTok business SDK will actually start sending app events to + // Events API when startTrack() function is called. Before this + // function is called, app events are merely stored locally. Delay + // calling this function if you need to let the user agree to data terms + // before actually sending the app events to TikTok. + TikTokBusinessSdk.startTrack(); + } + + static void LogEvent(EventName eventName) + { + TikTokBusinessSdk.trackTTEvent(eventName); + } + + public static void LogLoginEvent() + { + DotnetTikTokBinding.LogEvent(EventName.LOGIN); + } + + public static void LogRegistrationEvent() + { + DotnetTikTokBinding.LogEvent(EventName.REGISTRATION); + } + + public static void LogSubscribeEvent() + { + DotnetTikTokBinding.LogEvent(EventName.SUBSCRIBE); + } + + public static void LogSpendCreditsEvent() + { + DotnetTikTokBinding.LogEvent(EventName.SPEND_CREDITS); + } +} diff --git a/tiktok/android/native/settings.gradle.kts b/tiktok/android/native/settings.gradle.kts new file mode 100644 index 0000000..eed5ab7 --- /dev/null +++ b/tiktok/android/native/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + + // Add repository here, e.g. + maven { + url = uri("https://jitpack.io") + } + } +} + + + +rootProject.name = "MauiTikTok" +include(":mauitiktok") diff --git a/tiktok/macios/TikTok.MaciOS.Binding/ApiDefinition.cs b/tiktok/macios/TikTok.MaciOS.Binding/ApiDefinition.cs new file mode 100644 index 0000000..6efdf65 --- /dev/null +++ b/tiktok/macios/TikTok.MaciOS.Binding/ApiDefinition.cs @@ -0,0 +1,34 @@ +using Foundation; + +namespace MauiTikTokiOS +{ + // @interface DotnetTikTokBinding : NSObject + [BaseType (typeof(NSObject))] + interface DotnetTikTokBinding + { + // +(NSString * _Nonnull)getStringWithMyString:(NSString * _Nonnull)myString __attribute__((warn_unused_result(""))); + [Static] + [Export ("getStringWithMyString:")] + string GetString (string myString); + + [Static] + [Export("initTikTokWithAppId:tikTokAppId:isDebug:")] + bool InitTikTok(string appId, string tiktopAppId, bool isDebug); + + [Static] + [Export("logLoginEvent")] + void LogLoginEvent (); + + [Static] + [Export("logRegistrationEvent")] + void LogRegistrationEvent (); + + [Static] + [Export("logSubscribeEvent")] + void LogSubscribeEvent (); + + [Static] + [Export("logSpendCreditsEvent")] + void LogSpendCreditsEvent (); + } +} diff --git a/tiktok/macios/TikTok.MaciOS.Binding/StructsAndEnums.cs b/tiktok/macios/TikTok.MaciOS.Binding/StructsAndEnums.cs new file mode 100644 index 0000000..b3f570a --- /dev/null +++ b/tiktok/macios/TikTok.MaciOS.Binding/StructsAndEnums.cs @@ -0,0 +1,3 @@ +namespace MauiTikTokiOS.MaciOS.Binding { + +} diff --git a/tiktok/macios/TikTok.MaciOS.Binding/TikTok.MaciOS.Binding.csproj b/tiktok/macios/TikTok.MaciOS.Binding/TikTok.MaciOS.Binding.csproj new file mode 100644 index 0000000..0c979de --- /dev/null +++ b/tiktok/macios/TikTok.MaciOS.Binding/TikTok.MaciOS.Binding.csproj @@ -0,0 +1,32 @@ + + + net9.0-ios;net9.0-maccatalyst + enable + true + true + + + true + MauiTikTokiOS.MaciOS.Binding + + + + + + + + + + + TikTokBinding + + + + + diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.pbxproj b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.pbxproj new file mode 100644 index 0000000..d35caa7 --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.pbxproj @@ -0,0 +1,398 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 83E34F572C21CB2B008AA950 /* TikTokBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E34F562C21CB2B008AA950 /* TikTokBinding.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83E34F5E2C21CC53008AA950 /* DotnetTikTokBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E34F5D2C21CC53008AA950 /* DotnetTikTokBinding.swift */; }; + 9230E5CE2DA31F57002397DD /* TikTokBusinessSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 9230E5CD2DA31F57002397DD /* TikTokBusinessSDK */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 83E34F532C21CB2B008AA950 /* TikTokBinding.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TikTokBinding.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 83E34F562C21CB2B008AA950 /* TikTokBinding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TikTokBinding.h; sourceTree = ""; }; + 83E34F5D2C21CC53008AA950 /* DotnetTikTokBinding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DotnetTikTokBinding.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 83E34F502C21CB2B008AA950 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9230E5CE2DA31F57002397DD /* TikTokBusinessSDK in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 83E34F492C21CB2B008AA950 = { + isa = PBXGroup; + children = ( + 83E34F552C21CB2B008AA950 /* TikTokBinding */, + 83E34F542C21CB2B008AA950 /* Products */, + ); + sourceTree = ""; + }; + 83E34F542C21CB2B008AA950 /* Products */ = { + isa = PBXGroup; + children = ( + 83E34F532C21CB2B008AA950 /* TikTokBinding.framework */, + ); + name = Products; + sourceTree = ""; + }; + 83E34F552C21CB2B008AA950 /* TikTokBinding */ = { + isa = PBXGroup; + children = ( + 83E34F562C21CB2B008AA950 /* TikTokBinding.h */, + 83E34F5D2C21CC53008AA950 /* DotnetTikTokBinding.swift */, + ); + path = TikTokBinding; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 83E34F4E2C21CB2B008AA950 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 83E34F572C21CB2B008AA950 /* TikTokBinding.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 83E34F522C21CB2B008AA950 /* TikTokBinding */ = { + isa = PBXNativeTarget; + buildConfigurationList = 83E34F5A2C21CB2B008AA950 /* Build configuration list for PBXNativeTarget "TikTokBinding" */; + buildPhases = ( + 83E34F4E2C21CB2B008AA950 /* Headers */, + 83E34F4F2C21CB2B008AA950 /* Sources */, + 83E34F502C21CB2B008AA950 /* Frameworks */, + 83E34F512C21CB2B008AA950 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TikTokBinding; + productName = TikTokBinding; + productReference = 83E34F532C21CB2B008AA950 /* TikTokBinding.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 83E34F4A2C21CB2B008AA950 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1530; + TargetAttributes = { + 83E34F522C21CB2B008AA950 = { + CreatedOnToolsVersion = 15.3; + LastSwiftMigration = 1530; + }; + }; + }; + buildConfigurationList = 83E34F4D2C21CB2B008AA950 /* Build configuration list for PBXProject "TikTokBinding" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 83E34F492C21CB2B008AA950; + packageReferences = ( + 9230E5CC2DA31F57002397DD /* XCRemoteSwiftPackageReference "tiktok-business-ios-sdk" */, + ); + productRefGroup = 83E34F542C21CB2B008AA950 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 83E34F522C21CB2B008AA950 /* TikTokBinding */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 83E34F512C21CB2B008AA950 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 83E34F4F2C21CB2B008AA950 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83E34F5E2C21CC53008AA950 /* DotnetTikTokBinding.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 83E34F582C21CB2B008AA950 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 83E34F592C21CB2B008AA950 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SWIFT_COMPILATION_MODE = wholemodule; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 83E34F5B2C21CB2B008AA950 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES; + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = ( + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = ( + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 14.4; + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.tiktok; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = auto; + SKIP_INSTALL = NO; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 83E34F5C2C21CB2B008AA950 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES; + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = ( + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = ( + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 14.4; + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.tiktok; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = auto; + SKIP_INSTALL = NO; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 83E34F4D2C21CB2B008AA950 /* Build configuration list for PBXProject "TikTokBinding" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83E34F582C21CB2B008AA950 /* Debug */, + 83E34F592C21CB2B008AA950 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 83E34F5A2C21CB2B008AA950 /* Build configuration list for PBXNativeTarget "TikTokBinding" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83E34F5B2C21CB2B008AA950 /* Debug */, + 83E34F5C2C21CB2B008AA950 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 9230E5CC2DA31F57002397DD /* XCRemoteSwiftPackageReference "tiktok-business-ios-sdk" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/tiktok/tiktok-business-ios-sdk"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.3.8; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 9230E5CD2DA31F57002397DD /* TikTokBusinessSDK */ = { + isa = XCSwiftPackageProductDependency; + package = 9230E5CC2DA31F57002397DD /* XCRemoteSwiftPackageReference "tiktok-business-ios-sdk" */; + productName = TikTokBusinessSDK; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 83E34F4A2C21CB2B008AA950 /* Project object */; +} diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..ece11bd --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "e5d0f68effe33090a2fe9ffff53474a349a46eb9093528d7ce8c0e56fd3cd927", + "pins" : [ + { + "identity" : "tiktok-business-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/tiktok/tiktok-business-ios-sdk", + "state" : { + "revision" : "d701b7bcdf0274e4f5357245d5ae491f9fda2097", + "version" : "1.3.8" + } + } + ], + "version" : 3 +} diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding/DotnetTikTokBinding.swift b/tiktok/macios/native/TikTokBinding/TikTokBinding/DotnetTikTokBinding.swift new file mode 100644 index 0000000..81ac712 --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding/DotnetTikTokBinding.swift @@ -0,0 +1,81 @@ +// +// DotnetTikTokBinding.swift +// TikTok +// +// Created by .NET MAUI team on 6/18/24. +// Modified by Paul Demers on 4/10/25. +// + +import Foundation +import TikTokBusinessSDK + +@objc(DotnetTikTokBinding) +public class DotnetTikTokBinding : NSObject +{ + + @objc + public static func getString(myString: String) -> String { + return myString + " from swift!" + } + + @objc + public static func initTikTok(appId: String, tikTokAppId: String, isDebug: Bool) -> Bool { + + // This method will be depreacted in the future. Please use the latest method. + let config = TikTokConfig.init(appId: appId, tiktokAppId: tikTokAppId) + //let config = TikTokConfig(accessToken: accessToken, appId: appId, tiktokAppId: tikTokAppId) + + config?.enableDebugMode() + config?.setLogLevel(TikTokLogLevelDebug) //optional, recommended for diagnostics + + // You can init like this directly: + // TikTokBusiness.initializeSdk(config) + // But we recommend you using + // the new api with completionHandler below + TikTokBusiness.initializeSdk(config) { success, error in + if (!success) { // initialization failed + print("Tiktok init failed") + print(error!.localizedDescription) + } else { // initialization successful + print("Tiktok init success") + } + } + + return true + } + + @objc + public static func logLoginEvent() { + // Swift + let achieveLevelEvent = TikTokBaseEvent(name: TTEventName.login.rawValue) + TikTokBusiness.trackTTEvent(achieveLevelEvent) + } + + @objc + public static func logRegistrationEvent() { + // Swift + let achieveLevelEvent = TikTokBaseEvent(name: TTEventName.registration.rawValue) + TikTokBusiness.trackTTEvent(achieveLevelEvent) + } + + @objc + public static func logSubscribeEvent() { + // Swift + let achieveLevelEvent = TikTokBaseEvent(name: TTEventName.subscribe.rawValue) + TikTokBusiness.trackTTEvent(achieveLevelEvent) + } + + @objc + public static func logSpendCreditsEvent() { + // Swift + let achieveLevelEvent = TikTokBaseEvent(name: "SpendCredits") + TikTokBusiness.trackTTEvent(achieveLevelEvent) + } + + @objc + public static func logEvent(name: String) { + // Swift + let achieveLevelEvent = TikTokBaseEvent(name: name) + TikTokBusiness.trackTTEvent(achieveLevelEvent) + } +} diff --git a/tiktok/macios/native/TikTokBinding/TikTokBinding/TikTokBinding.h b/tiktok/macios/native/TikTokBinding/TikTokBinding/TikTokBinding.h new file mode 100644 index 0000000..fd75423 --- /dev/null +++ b/tiktok/macios/native/TikTokBinding/TikTokBinding/TikTokBinding.h @@ -0,0 +1,19 @@ +// +// TikTokBinding.h +// TikTokBinding +// +// Created by .NET MAUI team on 6/18/24. +// Modified by Paul Demers on 4/10/25. +// + +#import + +//! Project version number for TikTokBinding. +FOUNDATION_EXPORT double MauiTikTokVersionNumber; + +//! Project version string for TikTokBinding. +FOUNDATION_EXPORT const unsigned char MauiTikTokVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/tiktok/sample/App.xaml b/tiktok/sample/App.xaml new file mode 100644 index 0000000..f2a5334 --- /dev/null +++ b/tiktok/sample/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/tiktok/sample/App.xaml.cs b/tiktok/sample/App.xaml.cs new file mode 100644 index 0000000..8dc4fa8 --- /dev/null +++ b/tiktok/sample/App.xaml.cs @@ -0,0 +1,36 @@ +#if IOS || MACCATALYST +using TTBinding = MauiTikTokiOS.DotnetTikTokBinding; +#elif ANDROID +using TTBinding = MauiTikTokAndroid.DotnetTikTokBinding; +#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID) +using TTBinding = System.Object; +#endif + +namespace MauiSample; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } + + protected override void OnStart() + { + base.OnStart(); + +#if ANDROID + TTBinding.InitTikTok("", "", Android.App.Application.Context, true); +#elif IOS + TTBinding.InitTikTok("", "", true); +#endif + } +} + + + diff --git a/tiktok/sample/AppShell.xaml b/tiktok/sample/AppShell.xaml new file mode 100644 index 0000000..c1a4e5c --- /dev/null +++ b/tiktok/sample/AppShell.xaml @@ -0,0 +1,15 @@ + + + + + + diff --git a/tiktok/sample/AppShell.xaml.cs b/tiktok/sample/AppShell.xaml.cs new file mode 100644 index 0000000..f3db141 --- /dev/null +++ b/tiktok/sample/AppShell.xaml.cs @@ -0,0 +1,11 @@ + + +namespace MauiSample; + +public partial class AppShell : Shell +{ + public AppShell() + { + InitializeComponent(); + } +} diff --git a/tiktok/sample/MainPage.xaml b/tiktok/sample/MainPage.xaml new file mode 100644 index 0000000..e925b8c --- /dev/null +++ b/tiktok/sample/MainPage.xaml @@ -0,0 +1,53 @@ + + + + + + + +