├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── android ├── .gitignore ├── LICENSE ├── build.gradle.kts ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── plugin │ ├── .gitignore │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── dev │ │ └── msaba │ │ └── tracking │ │ └── transparency │ │ └── GodotAndroidPlugin.kt └── settings.gradle.kts ├── ios ├── .gitignore ├── TrackingTransparency.gdip ├── TrackingTransparency.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── TrackingTransparency.xcworkspace │ └── contents.xcworkspacedata └── TrackingTransparency │ ├── TrackingTransparency.h │ ├── TrackingTransparency.mm │ ├── TrackingTransparencyPlugin.h │ └── TrackingTransparencyPlugin.mm └── plugin ├── icon.png ├── plugin.cfg ├── plugin.gd └── tracking_node.gd /.gitignore: -------------------------------------------------------------------------------- 1 | xcode_plugin_build 2 | export 3 | .DS_Store 4 | .personal 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "godot"] 2 | path = godot 3 | url = https://github.com/godotengine/godot.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2025 Mohammad Sabaeian 2 | 3 | This plugin includes Android code originally from the Godot Android Plugin Template which is licensed under the MIT License by M4gr3d. See `/android/LICENSE` for details. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tracking Transparency for Godot 2 | 3 | A Godot plugin that provides a unified API for handling tracking transparency on both iOS and Android. This plugin allows you to request permission to track users and retrieve device advertising IDs in compliance with platform privacy requirements. 4 | 5 | ## Overview 6 | 7 | This plugin handles two main tracking-related features: 8 | 1. Requesting permission to track the user (required on iOS 14+ and respects opt-out settings on Android) 9 | 2. Retrieving the device advertising ID (IDFA on iOS, AAID on Android) 10 | 11 | ## Compatibility 12 | 13 | | Godot Version | Support 14 | |---------------|------------ 15 | | 4.4 | ✅ 16 | | 4.3 | ✅ 17 | | 4.2 | not tested 18 | | 3.x | ❌ 19 | 20 | 21 | ## Platform-Specific Behavior 22 | 23 | ### iOS 24 | - On iOS 14 and higher, the plugin will display Apple's App Tracking Transparency prompt to request permission 25 | - On iOS below 14, the plugin will always return `AUTHORIZED` status 26 | - On iOS 14 and later, the IDFA (Identifier for Advertisers) will only be available if tracking permission is granted 27 | 28 | ### Android 29 | - Returns `AUTHORIZED` if the user has not opted out of tracking, otherwise `DENIED` 30 | - The AAID (Android Advertising ID) will be null if the user has opted out of tracking 31 | 32 | ## Installation and setup 33 | 1. Install directly from the Asset Library tab in Godot (recommended): 34 | - if you installed using this method, jump to step 4 35 | 2. Manual Installation: 36 | - Download the latest version from the Releases section 37 | - Copy the `addons/tracking_transparency` folder to your Godot project's `addons` directory 38 | 3. Enable the plugin in `Project Settings → Plugins` 39 | 4. Platforms configuration: 40 | - Android: 41 | - Enable [Use Gradle Build](https://docs.godotengine.org/en/stable/tutorials/export/android_gradle_build.html) in your export settings 42 | - iOS: 43 | - Copy the files inside `addons/tracking_transparency/ios/[YOUR_GODOT_VERSION]` into the `ios/plugins` folder located at the root of your project (create this folder if it does not exist) 44 | - Check the "Tracking Transparency" option under `Project → Export → iOS → Plugins` 45 | - Add a tracking usage description in `Project → Export → iOS → Plugins Plist` by setting the `NSUserTrackingUsageDescription` key, you must provide a clear reason for tracking or Apple will reject your app/game during review 46 | 47 | ## Usage 48 | 49 | **Note:** This plugin adds a singleton to your project runtime. If you want to have a node instead, you need to modify the plugin.gd file and use `add_custom_type` instead of `add_autoload_singleton`. 50 | 51 | ### Basic Implementation 52 | 53 | ```gdscript 54 | extends Node 55 | 56 | func _ready(): 57 | # Connect to the authorization status signal 58 | TrackingTransparency.authorization_status_received.connect(_on_authorization_status_received) 59 | 60 | # Request tracking permission 61 | TrackingTransparency.request_permission() 62 | 63 | # Handle the authorization result 64 | func _on_authorization_status_received(status): 65 | match status: 66 | TrackingTransparency.AuthorizationStatus.AUTHORIZED: 67 | print("Advertising ID:", TrackingTransparency.get_advertising_id()) 68 | TrackingTransparency.AuthorizationStatus.DENIED: 69 | print("Tracking denied by user") 70 | TrackingTransparency.AuthorizationStatus.RESTRICTED: 71 | print("Tracking restricted (usually by parental controls)") 72 | TrackingTransparency.AuthorizationStatus.NOT_DETERMINED: 73 | print("Tracking permission not determined yet") 74 | ``` 75 | 76 | ## API Reference 77 | 78 | ### Enumerations 79 | 80 | ```gdscript 81 | enum AuthorizationStatus { 82 | NOT_DETERMINED = 0, # User has not been asked for permission yet 83 | RESTRICTED, # Tracking is restricted (e.g., parental controls) 84 | DENIED, # User has denied tracking permission 85 | AUTHORIZED, # User has authorized tracking 86 | } 87 | ``` 88 | 89 | ### Methods 90 | 91 | #### `request_permission()` 92 | Requests permission from the user to track them and emits the result by emitting `authorization_status_received` 93 | - On iOS 14+: displays the system tracking permission dialog 94 | - On iOS 13 and earlier: always emit `AUTHORIZED` 95 | - On iOS simulator, 96 | - On Android: no user prompt appears but the status will be check and emitted 97 | 98 | #### `get_advertising_id()` 99 | Returns the advertising ID as a string, or `null` if unavailable or not authorized 100 | - On iOS: Returns the IDFA (Identifier for Advertisers) 101 | - On Android: Returns the AAID (Android Advertising ID) 102 | - On iOS simulator: Always returns `null` 103 | 104 | #### `open_app_settings()` 105 | _(iOS only)_ 106 | Opens the application settings page. Useful for directing users to change their tracking preferences if they've denied the permission before 107 | 108 | #### `get_tracking_authorization_status()` 109 | Returns the current authorization status without requesting permission 110 | - On iOS below 14: Always returns `AUTHORIZED` 111 | - On Android: Returns `AUTHORIZED` if the user has not opted out of tracking, otherwise `DENIED` 112 | 113 | ### Signals 114 | 115 | #### `authorization_status_received(status: AuthorizationStatus)` 116 | Emitted when an authorization status is received after calling `request_permission()`. 117 | 118 | 119 | ## License 120 | 121 | This plugin is released under the MIT License. See the [LICENSE](LICENSE) file for details. 122 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # Log/OS Files 9 | *.log 10 | 11 | # Android Studio generated files and folders 12 | captures/ 13 | .externalNativeBuild/ 14 | .cxx/ 15 | *.apk 16 | output.json 17 | 18 | # IntelliJ 19 | *.iml 20 | .idea/ 21 | misc.xml 22 | deploymentTargetDropDown.xml 23 | render.experimental.xml 24 | 25 | # Keystore files 26 | *.jks 27 | *.keystore 28 | 29 | # Google Services (e.g. APIs or Firebase) 30 | google-services.json 31 | 32 | # Android Profiling 33 | *.hprof 34 | -------------------------------------------------------------------------------- /android/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Fredia Huya-Kouadio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id("com.android.library") version "7.4.1" apply false 4 | id("org.jetbrains.kotlin.android") version "1.8.0" apply false 5 | } 6 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true 24 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msabaeian/tracking-transparency/bb3dfb326667e5c2f9bed92e8c66b0078943aa4d/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /android/plugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /android/plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.android.build.gradle.internal.tasks.factory.dependsOn 2 | 3 | plugins { 4 | id("com.android.library") 5 | id("org.jetbrains.kotlin.android") 6 | } 7 | 8 | val pluginName = "TrackingTransparency" 9 | 10 | val pluginPackageName = "msaba.dev.tracking.transparency" 11 | 12 | android { 13 | namespace = pluginPackageName 14 | compileSdk = 33 15 | 16 | buildFeatures { 17 | buildConfig = true 18 | } 19 | 20 | defaultConfig { 21 | minSdk = 21 22 | 23 | manifestPlaceholders["godotPluginName"] = pluginName 24 | manifestPlaceholders["godotPluginPackageName"] = pluginPackageName 25 | buildConfigField("String", "GODOT_PLUGIN_NAME", "\"${pluginName}\"") 26 | setProperty("archivesBaseName", pluginName) 27 | } 28 | 29 | compileOptions { 30 | sourceCompatibility = JavaVersion.VERSION_17 31 | targetCompatibility = JavaVersion.VERSION_17 32 | } 33 | kotlinOptions { 34 | jvmTarget = "17" 35 | } 36 | } 37 | 38 | dependencies { 39 | implementation("org.godotengine:godot:4.3.0.stable") 40 | implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") 41 | } 42 | 43 | tasks.named("assemble").configure { 44 | 45 | } 46 | 47 | tasks.named("clean").apply { 48 | 49 | } 50 | -------------------------------------------------------------------------------- /android/plugin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/plugin/src/main/java/dev/msaba/tracking/transparency/GodotAndroidPlugin.kt: -------------------------------------------------------------------------------- 1 | package msaba.dev.tracking.transparency 2 | 3 | import org.godotengine.godot.Godot 4 | import org.godotengine.godot.plugin.GodotPlugin 5 | import org.godotengine.godot.plugin.UsedByGodot 6 | import com.google.android.gms.ads.identifier.AdvertisingIdClient 7 | 8 | class GodotAndroidPlugin(godot: Godot): GodotPlugin(godot) { 9 | 10 | override fun getPluginName() = BuildConfig.GODOT_PLUGIN_NAME 11 | 12 | @UsedByGodot 13 | fun getAdvertisingId(): String? { 14 | return activity?.let { AdvertisingIdClient.getAdvertisingIdInfo(it.applicationContext).id } 15 | } 16 | 17 | @UsedByGodot 18 | fun isLimitAdTrackingEnabled(): Boolean? { 19 | return activity?.let { AdvertisingIdClient.getAdvertisingIdInfo(it.applicationContext).isLimitAdTrackingEnabled } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | maven("https://plugins.gradle.org/m2/") 14 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") 15 | } 16 | } 17 | 18 | rootProject.name = "TrackingTransparency" 19 | include(":plugin") 20 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | xcuserdata/ 2 | *.xcscmblueprint 3 | *.xccheckout 4 | build/ 5 | DerivedData/ 6 | *.moved-aside 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | -------------------------------------------------------------------------------- /ios/TrackingTransparency.gdip: -------------------------------------------------------------------------------- 1 | [config] 2 | name="TrackingTransparency" 3 | binary="TrackingTransparency.xcframework" 4 | initialization="TrackingTransparencyInitialize" 5 | deinitialization="TrackingTransparencyTerminate" 6 | 7 | [dependencies] 8 | linked=[] 9 | embedded=[] 10 | system=["Foundation.framework"] 11 | capabilities=[""] 12 | files=[] 13 | linker_flags=["-ObjC"] 14 | 15 | [plist] 16 | NSUserTrackingUsageDescription:string_input="" 17 | -------------------------------------------------------------------------------- /ios/TrackingTransparency.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 77; 7 | objects = { 8 | 9 | /* Begin PBXCopyFilesBuildPhase section */ 10 | 16E8CB702D809E9300D725AF /* CopyFiles */ = { 11 | isa = PBXCopyFilesBuildPhase; 12 | buildActionMask = 2147483647; 13 | dstPath = "include/$(PRODUCT_NAME)"; 14 | dstSubfolderSpec = 16; 15 | files = ( 16 | ); 17 | runOnlyForDeploymentPostprocessing = 0; 18 | }; 19 | /* End PBXCopyFilesBuildPhase section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 16E8CB722D809E9300D725AF /* libTrackingTransparency.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTrackingTransparency.a; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */ 26 | 16E8CB792D809E9300D725AF /* Exceptions for "TrackingTransparency" folder in "Copy Files" phase from "TrackingTransparency" target */ = { 27 | isa = PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet; 28 | buildPhase = 16E8CB702D809E9300D725AF /* CopyFiles */; 29 | membershipExceptions = ( 30 | TrackingTransparency.h, 31 | ); 32 | }; 33 | /* End PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */ 34 | 35 | /* Begin PBXFileSystemSynchronizedRootGroup section */ 36 | 16E8CB742D809E9300D725AF /* TrackingTransparency */ = { 37 | isa = PBXFileSystemSynchronizedRootGroup; 38 | exceptions = ( 39 | 16E8CB792D809E9300D725AF /* Exceptions for "TrackingTransparency" folder in "Copy Files" phase from "TrackingTransparency" target */, 40 | ); 41 | path = TrackingTransparency; 42 | sourceTree = ""; 43 | }; 44 | /* End PBXFileSystemSynchronizedRootGroup section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 16E8CB6F2D809E9300D725AF /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 16E8CB692D809E9300D725AF = { 58 | isa = PBXGroup; 59 | children = ( 60 | 16E8CB742D809E9300D725AF /* TrackingTransparency */, 61 | 16E8CB732D809E9300D725AF /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | 16E8CB732D809E9300D725AF /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 16E8CB722D809E9300D725AF /* libTrackingTransparency.a */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 16E8CB712D809E9300D725AF /* TrackingTransparency */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 16E8CB7C2D809E9300D725AF /* Build configuration list for PBXNativeTarget "TrackingTransparency" */; 79 | buildPhases = ( 80 | 16E8CB6E2D809E9300D725AF /* Sources */, 81 | 16E8CB6F2D809E9300D725AF /* Frameworks */, 82 | 16E8CB702D809E9300D725AF /* CopyFiles */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | fileSystemSynchronizedGroups = ( 89 | 16E8CB742D809E9300D725AF /* TrackingTransparency */, 90 | ); 91 | name = TrackingTransparency; 92 | packageProductDependencies = ( 93 | ); 94 | productName = TrackingTransparency; 95 | productReference = 16E8CB722D809E9300D725AF /* libTrackingTransparency.a */; 96 | productType = "com.apple.product-type.library.static"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | 16E8CB6A2D809E9300D725AF /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | BuildIndependentTargetsInParallel = 1; 105 | LastUpgradeCheck = 1620; 106 | TargetAttributes = { 107 | 16E8CB712D809E9300D725AF = { 108 | CreatedOnToolsVersion = 16.2; 109 | LastSwiftMigration = 1620; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = 16E8CB6D2D809E9300D725AF /* Build configuration list for PBXProject "TrackingTransparency" */; 114 | developmentRegion = en; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | Base, 119 | ); 120 | mainGroup = 16E8CB692D809E9300D725AF; 121 | minimizedProjectReferenceProxies = 1; 122 | preferredProjectObjectVersion = 77; 123 | productRefGroup = 16E8CB732D809E9300D725AF /* Products */; 124 | projectDirPath = ""; 125 | projectRoot = ""; 126 | targets = ( 127 | 16E8CB712D809E9300D725AF /* TrackingTransparency */, 128 | ); 129 | }; 130 | /* End PBXProject section */ 131 | 132 | /* Begin PBXSourcesBuildPhase section */ 133 | 16E8CB6E2D809E9300D725AF /* Sources */ = { 134 | isa = PBXSourcesBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXSourcesBuildPhase section */ 141 | 142 | /* Begin XCBuildConfiguration section */ 143 | 16E8CB7A2D809E9300D725AF /* Debug */ = { 144 | isa = XCBuildConfiguration; 145 | buildSettings = { 146 | ALWAYS_SEARCH_USER_PATHS = NO; 147 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 148 | CLANG_ANALYZER_NONNULL = YES; 149 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 150 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 151 | CLANG_ENABLE_MODULES = YES; 152 | CLANG_ENABLE_OBJC_ARC = YES; 153 | CLANG_ENABLE_OBJC_WEAK = YES; 154 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 155 | CLANG_WARN_BOOL_CONVERSION = YES; 156 | CLANG_WARN_COMMA = YES; 157 | CLANG_WARN_CONSTANT_CONVERSION = YES; 158 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 159 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 160 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 161 | CLANG_WARN_EMPTY_BODY = YES; 162 | CLANG_WARN_ENUM_CONVERSION = YES; 163 | CLANG_WARN_INFINITE_RECURSION = YES; 164 | CLANG_WARN_INT_CONVERSION = YES; 165 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 166 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 167 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 168 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 169 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 170 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 171 | CLANG_WARN_STRICT_PROTOTYPES = YES; 172 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 173 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 174 | CLANG_WARN_UNREACHABLE_CODE = YES; 175 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 176 | COPY_PHASE_STRIP = NO; 177 | DEBUG_INFORMATION_FORMAT = dwarf; 178 | ENABLE_STRICT_OBJC_MSGSEND = YES; 179 | ENABLE_TESTABILITY = YES; 180 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 181 | GCC_C_LANGUAGE_STANDARD = gnu17; 182 | GCC_DYNAMIC_NO_PIC = NO; 183 | GCC_NO_COMMON_BLOCKS = YES; 184 | GCC_OPTIMIZATION_LEVEL = 0; 185 | GCC_PREPROCESSOR_DEFINITIONS = ( 186 | "DEBUG=1", 187 | "$(inherited)", 188 | ); 189 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 190 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 191 | GCC_WARN_UNDECLARED_SELECTOR = YES; 192 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 193 | GCC_WARN_UNUSED_FUNCTION = YES; 194 | GCC_WARN_UNUSED_VARIABLE = YES; 195 | IPHONEOS_DEPLOYMENT_TARGET = 18.2; 196 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 197 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 198 | MTL_FAST_MATH = YES; 199 | ONLY_ACTIVE_ARCH = YES; 200 | SDKROOT = iphoneos; 201 | }; 202 | name = Debug; 203 | }; 204 | 16E8CB7B2D809E9300D725AF /* Release */ = { 205 | isa = XCBuildConfiguration; 206 | buildSettings = { 207 | ALWAYS_SEARCH_USER_PATHS = NO; 208 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 209 | CLANG_ANALYZER_NONNULL = YES; 210 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 211 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 212 | CLANG_ENABLE_MODULES = YES; 213 | CLANG_ENABLE_OBJC_ARC = YES; 214 | CLANG_ENABLE_OBJC_WEAK = YES; 215 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 216 | CLANG_WARN_BOOL_CONVERSION = YES; 217 | CLANG_WARN_COMMA = YES; 218 | CLANG_WARN_CONSTANT_CONVERSION = YES; 219 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 220 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 221 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 222 | CLANG_WARN_EMPTY_BODY = YES; 223 | CLANG_WARN_ENUM_CONVERSION = YES; 224 | CLANG_WARN_INFINITE_RECURSION = YES; 225 | CLANG_WARN_INT_CONVERSION = YES; 226 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 227 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 228 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 229 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 230 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 231 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 232 | CLANG_WARN_STRICT_PROTOTYPES = YES; 233 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 234 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 235 | CLANG_WARN_UNREACHABLE_CODE = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | COPY_PHASE_STRIP = NO; 238 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 239 | ENABLE_NS_ASSERTIONS = NO; 240 | ENABLE_STRICT_OBJC_MSGSEND = YES; 241 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 242 | GCC_C_LANGUAGE_STANDARD = gnu17; 243 | GCC_NO_COMMON_BLOCKS = YES; 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 18.2; 251 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 252 | MTL_ENABLE_DEBUG_INFO = NO; 253 | MTL_FAST_MATH = YES; 254 | SDKROOT = iphoneos; 255 | VALIDATE_PRODUCT = YES; 256 | }; 257 | name = Release; 258 | }; 259 | 16E8CB7D2D809E9300D725AF /* Debug */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | CLANG_ENABLE_MODULES = YES; 263 | CODE_SIGN_STYLE = Automatic; 264 | DEVELOPMENT_TEAM = YP99R6Q5HP; 265 | HEADER_SEARCH_PATHS = ( 266 | "\"$(SRCROOT)/../godot\"", 267 | "\"$(SRCROOT)/../godot/platform/ios\"", 268 | ); 269 | OTHER_CFLAGS = ( 270 | "-g", 271 | "-DDEBUG", 272 | "-DDEBUG_ENABLED", 273 | "-DDEBUG_MEMORY_ALLOC", 274 | "-DDISABLE_FORCED_INLINE", 275 | "-DTYPED_METHOD_BIND", 276 | "-fmodules", 277 | "-fobjc-arc", 278 | "-fno-strict-aliasing", 279 | "-fblocks", 280 | "-fvisibility=hidden", 281 | "-fno-exceptions", 282 | "-Wall", 283 | "-Werror=return-type", 284 | "-DPTRCALL_ENABLED", 285 | ); 286 | OTHER_CPLUSPLUSFLAGS = ( 287 | "-fcxx-modules", 288 | "-gdwarf-2", 289 | "-O0", 290 | "-DDEBUG_MEMORY_ALLOC", 291 | "-DDISABLE_FORCED_INLINE", 292 | "-D_DEBUG", 293 | "-DDEBUG=1", 294 | "-DDEBUG_ENABLED", 295 | "-DVERSION_4_0", 296 | "-DIOS_ENABLED", 297 | "-DNEED_LONG_INT", 298 | "-DLIBYUV_DISABLE_NEON", 299 | "-DIPHONE_ENABLED", 300 | "-DUNIX_ENABLED", 301 | "-DCOREAUDIO_ENABLED", 302 | ); 303 | OTHER_LDFLAGS = "-ObjC"; 304 | PRODUCT_NAME = "$(TARGET_NAME)"; 305 | SKIP_INSTALL = NO; 306 | SWIFT_OBJC_BRIDGING_HEADER = ""; 307 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 308 | SWIFT_VERSION = 6.0; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | }; 311 | name = Debug; 312 | }; 313 | 16E8CB7E2D809E9300D725AF /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | CLANG_ENABLE_MODULES = YES; 317 | CODE_SIGN_STYLE = Automatic; 318 | DEVELOPMENT_TEAM = YP99R6Q5HP; 319 | HEADER_SEARCH_PATHS = ( 320 | "\"$(SRCROOT)/../godot\"", 321 | "\"$(SRCROOT)/../godot/platform/ios\"", 322 | ); 323 | OTHER_CFLAGS = ( 324 | "-fmodules", 325 | "-fobjc-arc", 326 | "-fno-strict-aliasing", 327 | "-fblocks", 328 | "-fvisibility=hidden", 329 | "-fno-exceptions", 330 | "-Wall", 331 | "-Werror=return-type", 332 | "-DPTRCALL_ENABLED", 333 | ); 334 | OTHER_CPLUSPLUSFLAGS = ( 335 | "-fcxx-modules", 336 | "-O2", 337 | "-ftree-vectorize", 338 | "-DNDEBUG", 339 | "-DNS_BLOCK_ASSERTIONS=1", 340 | "-DVERSION_4_0", 341 | "-DIOS_ENABLED", 342 | "-DNEED_LONG_INT", 343 | "-DLIBYUV_DISABLE_NEON", 344 | "-DIPHONE_ENABLED", 345 | "-DUNIX_ENABLED", 346 | "-DCOREAUDIO_ENABLED", 347 | ); 348 | OTHER_LDFLAGS = "-ObjC"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | SKIP_INSTALL = NO; 351 | SWIFT_OBJC_BRIDGING_HEADER = ""; 352 | SWIFT_VERSION = 6.0; 353 | TARGETED_DEVICE_FAMILY = "1,2"; 354 | }; 355 | name = Release; 356 | }; 357 | /* End XCBuildConfiguration section */ 358 | 359 | /* Begin XCConfigurationList section */ 360 | 16E8CB6D2D809E9300D725AF /* Build configuration list for PBXProject "TrackingTransparency" */ = { 361 | isa = XCConfigurationList; 362 | buildConfigurations = ( 363 | 16E8CB7A2D809E9300D725AF /* Debug */, 364 | 16E8CB7B2D809E9300D725AF /* Release */, 365 | ); 366 | defaultConfigurationIsVisible = 0; 367 | defaultConfigurationName = Release; 368 | }; 369 | 16E8CB7C2D809E9300D725AF /* Build configuration list for PBXNativeTarget "TrackingTransparency" */ = { 370 | isa = XCConfigurationList; 371 | buildConfigurations = ( 372 | 16E8CB7D2D809E9300D725AF /* Debug */, 373 | 16E8CB7E2D809E9300D725AF /* Release */, 374 | ); 375 | defaultConfigurationIsVisible = 0; 376 | defaultConfigurationName = Release; 377 | }; 378 | /* End XCConfigurationList section */ 379 | }; 380 | rootObject = 16E8CB6A2D809E9300D725AF /* Project object */; 381 | } 382 | -------------------------------------------------------------------------------- /ios/TrackingTransparency.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/TrackingTransparency.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/TrackingTransparency/TrackingTransparency.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/object/object.h" 4 | #include "core/object/class_db.h" 5 | 6 | extern String const PERMISSION_AUTHORIZATION_RECEIVED; 7 | 8 | 9 | class TrackingTransparency : public Object { 10 | GDCLASS(TrackingTransparency, Object); 11 | static void _bind_methods(); 12 | 13 | public: 14 | int getTrackingAuthorizationStatus(); 15 | String getAdvertisingId(); 16 | void requestPermission(); 17 | void openAppSettings(); 18 | 19 | TrackingTransparency(); 20 | ~TrackingTransparency(); 21 | }; 22 | -------------------------------------------------------------------------------- /ios/TrackingTransparency/TrackingTransparency.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import "TrackingTransparency.h" 3 | #import 4 | #import 5 | #import 6 | 7 | String const PERMISSION_AUTHORIZATION_RECEIVED = "permission_authorization_received"; 8 | 9 | void TrackingTransparency::_bind_methods() { 10 | ClassDB::bind_method(D_METHOD("getTrackingAuthorizationStatus"), &TrackingTransparency::getTrackingAuthorizationStatus); 11 | ClassDB::bind_method(D_METHOD("requestPermission"), &TrackingTransparency::requestPermission); 12 | ClassDB::bind_method(D_METHOD("getAdvertisingId"), &TrackingTransparency::getAdvertisingId); 13 | ClassDB::bind_method(D_METHOD("openAppSettings"), &TrackingTransparency::openAppSettings); 14 | ADD_SIGNAL(MethodInfo(PERMISSION_AUTHORIZATION_RECEIVED, PropertyInfo(Variant::INT, "result"))); 15 | } 16 | 17 | String TrackingTransparency::getAdvertisingId() { 18 | return [[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString] UTF8String]; 19 | } 20 | 21 | void TrackingTransparency::requestPermission() { 22 | if (@available(iOS 14, *)) { 23 | if (![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSUserTrackingUsageDescription"]) { 24 | ERR_PRINT("TrackingTransparency: NSUserTrackingUsageDescription not found"); 25 | emit_signal(PERMISSION_AUTHORIZATION_RECEIVED, (int)ATTrackingManagerAuthorizationStatusDenied); 26 | return; 27 | } 28 | 29 | [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { 30 | dispatch_async(dispatch_get_main_queue(), ^{ 31 | emit_signal(PERMISSION_AUTHORIZATION_RECEIVED, (int)status); 32 | }); 33 | }]; 34 | return; 35 | } 36 | 37 | emit_signal(PERMISSION_AUTHORIZATION_RECEIVED, (int)ATTrackingManagerAuthorizationStatusAuthorized); 38 | } 39 | 40 | void TrackingTransparency::openAppSettings() { 41 | NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; 42 | if ([[UIApplication sharedApplication] canOpenURL:settingsURL]) { 43 | [[UIApplication sharedApplication] openURL:settingsURL options:@{} completionHandler:^(BOOL success) { 44 | if (!success) { 45 | ERR_PRINT("TrackingTransparency: Failed to open app settings."); 46 | } 47 | }]; 48 | return; 49 | } 50 | 51 | ERR_PRINT("TrackingTransparency: Cannot open app settings."); 52 | } 53 | 54 | int TrackingTransparency::getTrackingAuthorizationStatus() { 55 | if (@available(iOS 14, *)) { 56 | return (int)[ATTrackingManager trackingAuthorizationStatus]; 57 | } 58 | return (int)ATTrackingManagerAuthorizationStatusAuthorized; 59 | } 60 | 61 | 62 | TrackingTransparency::TrackingTransparency() { 63 | print_verbose("TrackingTransparency: init"); 64 | } 65 | 66 | TrackingTransparency::~TrackingTransparency() { 67 | print_verbose("TrackingTransparency: deinit"); 68 | } 69 | -------------------------------------------------------------------------------- /ios/TrackingTransparency/TrackingTransparencyPlugin.h: -------------------------------------------------------------------------------- 1 | void TrackingTransparencyInitialize(); 2 | void TrackingTransparencyTerminate(); 3 | -------------------------------------------------------------------------------- /ios/TrackingTransparency/TrackingTransparencyPlugin.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import "TrackingTransparency.h" 3 | #import "TrackingTransparencyPlugin.h" 4 | #import "core/config/engine.h" 5 | 6 | TrackingTransparency *plugin; 7 | 8 | void TrackingTransparencyInitialize() { 9 | plugin = memnew(TrackingTransparency); 10 | Engine::get_singleton()->add_singleton(Engine::Singleton("TrackingTransparency", plugin)); 11 | } 12 | 13 | void TrackingTransparencyTerminate() { 14 | if (plugin) { 15 | memdelete(plugin); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /plugin/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msabaeian/tracking-transparency/bb3dfb326667e5c2f9bed92e8c66b0078943aa4d/plugin/icon.png -------------------------------------------------------------------------------- /plugin/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="Tracking Transparency" 4 | description="a plugin to request permission to track the user or their device and retrieve advertising id" 5 | author="Mohammad Sabaeian" 6 | version="1.0" 7 | script="plugin.gd" 8 | -------------------------------------------------------------------------------- /plugin/plugin.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends EditorPlugin 3 | 4 | var android_export_plugin: TrackingTransparencyAndroidExportPlugin 5 | 6 | func _enter_tree() -> void: 7 | android_export_plugin = TrackingTransparencyAndroidExportPlugin.new() 8 | add_autoload_singleton("TrackingTransparency", "tracking_node.gd") 9 | add_export_plugin(android_export_plugin) 10 | 11 | func _exit_tree() -> void: 12 | remove_export_plugin(android_export_plugin) 13 | android_export_plugin = null 14 | 15 | class TrackingTransparencyAndroidExportPlugin extends EditorExportPlugin: 16 | var _plugin_name = "TrackingTransparency" 17 | 18 | func _supports_platform(platform): 19 | return platform is EditorExportPlatformAndroid 20 | 21 | func _get_android_libraries(_platform, debug): 22 | if debug: 23 | return PackedStringArray(["tracking_transparency/bin/debug/" + _plugin_name + "-debug.aar"]) 24 | return PackedStringArray(["tracking_transparency/bin/release/" + _plugin_name + "-release.aar"]) 25 | 26 | func _get_android_dependencies(_platform, _debug): 27 | return PackedStringArray(["com.google.android.gms:play-services-ads-identifier:18.0.1"]) 28 | 29 | func _get_android_manifest_element_contents(_platform, _debug): 30 | return '' 31 | 32 | func _get_name(): 33 | return _plugin_name 34 | -------------------------------------------------------------------------------- /plugin/tracking_node.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends Node 3 | 4 | signal authorization_status_received(status: AuthorizationStatus) 5 | 6 | enum AuthorizationStatus { 7 | NOT_DETERMINED = 0, 8 | RESTRICTED, 9 | DENIED, 10 | AUTHORIZED, 11 | } 12 | 13 | var _plugin 14 | 15 | func _ready(): 16 | if Engine.has_singleton("TrackingTransparency"): 17 | _plugin = Engine.get_singleton("TrackingTransparency") 18 | 19 | if _plugin.has_signal("permission_authorization_received"): 20 | _plugin.connect("permission_authorization_received", _on_authorization_status_received) 21 | 22 | ## requests permission from the user to track them 23 | ## the result is emitted through the authorization_status_received signal 24 | ## on iOS below 14, always emits AUTHORIZED 25 | ## on Android, this emits AUTHORIZED if the user has not opted out of tracking, otherwise DENIED 26 | func request_permission(): 27 | if not _plugin: 28 | return 29 | 30 | match OS.get_name(): 31 | "iOS": 32 | _plugin.requestPermission() 33 | "Android": 34 | _on_authorization_status_received(_get_android_authorization_status()) 35 | 36 | ## returns the advertising ID 37 | ## on iOS, this is the [url=https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier]IDFA[/url] 38 | ## on Android, this is the [url=https://support.google.com/googleplay/android-developer/answer/6048248?hl=en]Android Advertising ID[/url] 39 | ## on iOS 14 and above, this returns null if the permission is not granted 40 | ## on Android, this returns null if the permission is not granted 41 | func get_advertising_id(): 42 | if not _plugin: 43 | return null 44 | 45 | var id = _plugin.getAdvertisingId() 46 | return id if id && id != "00000000-0000-0000-0000-000000000000" else null 47 | 48 | ## opens the app settings to allow the user to change the permission 49 | ## only available on iOS 50 | func open_app_settings(): 51 | if not _plugin or OS.get_name() != "iOS": 52 | return 53 | _plugin.openAppSettings() 54 | 55 | ## returns the tracking authorization status 56 | ## on iOS below 14, this always returns AUTHORIZED 57 | ## on Android, this returns AUTHORIZED if the user has not opted out of tracking, otherwise DENIED 58 | func get_tracking_authorization_status(): 59 | if not _plugin: 60 | return null 61 | 62 | match OS.get_name(): 63 | "iOS": 64 | return _plugin.getTrackingAuthorizationStatus() 65 | "Android": 66 | return _get_android_authorization_status() 67 | _: 68 | return null 69 | 70 | func _on_authorization_status_received(status): 71 | authorization_status_received.emit(status) 72 | 73 | func _get_android_authorization_status(): 74 | return AuthorizationStatus.AUTHORIZED if not _plugin.isLimitAdTrackingEnabled() else AuthorizationStatus.DENIED 75 | --------------------------------------------------------------------------------