diff --git a/CapacitorLevelplay.podspec b/CapacitorLevelplay.podspec index cad99e2..e285827 100644 --- a/CapacitorLevelplay.podspec +++ b/CapacitorLevelplay.podspec @@ -1,18 +1,21 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) +repo = 'https://git.crt.fyi/CRT/capacitor-levelplay' Pod::Spec.new do |s| s.name = 'CapacitorLevelplay' s.version = package['version'] - s.summary = package['description'] + s.summary = 'Capacitor plugin for Unity LevelPlay rewarded and interstitial ads.' + s.description = package['description'] s.license = package['license'] - s.homepage = package['repository']['url'] - s.author = package['author'] - s.source = { :git => package['repository']['url'], :tag => 'v' + package['version'] } + s.homepage = package['homepage'] + s.author = package['author']['name'] + s.source = { :git => "#{repo}.git", :tag => "v#{s.version}" } s.source_files = 'ios/Sources/**/*.{swift,h,m}' s.ios.deployment_target = '15.0' s.dependency 'Capacitor' + # Unity LevelPlay SDK (ironSource), https://cocoapods.org/pods/IronSourceSDK s.dependency 'IronSourceSDK', '~> 9.6.1' s.frameworks = 'AppTrackingTransparency' s.swift_version = '5.9' diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..23192e2 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +# Standalone build of the plugin library (`bun run verify:android`). Not used by consuming apps. +org.gradle.jvmargs=-Xmx1536m +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7705927 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..23d15a9 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# 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 ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# 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 + if ! command -v java >/dev/null 2>&1 + then + 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 +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# 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"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..5eed7ee --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,94 @@ +@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 +@rem SPDX-License-Identifier: Apache-2.0 +@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=. +@rem This is normally unused +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% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..1c79088 --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,4 @@ +// Standalone build of the plugin library, used by `bun run verify:android` (needs `bun install` first). +// Consuming apps do not use this file: `npx cap sync` includes the module from their own settings. +include ':capacitor-android' +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') diff --git a/dist/docs.json b/dist/docs.json new file mode 100644 index 0000000..8ab1068 --- /dev/null +++ b/dist/docs.json @@ -0,0 +1,1323 @@ +{ + "api": { + "name": "LevelPlayPlugin", + "slug": "levelplayplugin", + "docs": "Unity LevelPlay rewarded and interstitial ads (ad-unit API).", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [ + { + "name": "initialize", + "signature": "(options: InitOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "InitOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Initialise the LevelPlay SDK (`LevelPlay.init`). Resolves on init success, rejects with the init error\n(code and message from the SDK) otherwise. Calling it again after a successful init resolves immediately;\nconcurrent calls share one init. Load ads only after this resolves.\n\nSet consent (and on iOS ask for ATT) before calling it.\n\nOn the web it rejects as unimplemented.", + "complexTypes": [ + "InitResult", + "InitOptions" + ], + "slug": "initialize" + }, + { + "name": "getSdkVersion", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Native LevelPlay SDK version. Works before init.", + "complexTypes": [ + "InitResult" + ], + "slug": "getsdkversion" + }, + { + "name": "setConsent", + "signature": "(options: ConsentOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "ConsentOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Forward GDPR / CCPA / COPPA signals to LevelPlay. Call it before `initialize()` when you\ncan, and again whenever the user changes their choice.", + "complexTypes": [ + "ConsentOptions" + ], + "slug": "setconsent" + }, + { + "name": "setMetaData", + "signature": "(options: MetaDataOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "MetaDataOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Raw `LevelPlay.setMetaData(key, value)` for SDK or network-specific flags. Call it before init.", + "complexTypes": [ + "MetaDataOptions" + ], + "slug": "setmetadata" + }, + { + "name": "requestTrackingAuthorization", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "iOS: show the App Tracking Transparency prompt and resolve with the resulting status. Needs\n`NSUserTrackingUsageDescription` in `Info.plist`. iOS only shows the prompt once; later calls resolve the stored\nstatus. Call it before `initialize()`, while the app is active.\n\nAndroid and web: resolves `unavailable`.", + "complexTypes": [ + "TrackingResult" + ], + "slug": "requesttrackingauthorization" + }, + { + "name": "getTrackingAuthorizationStatus", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Current App Tracking Transparency status without prompting (iOS). Android and web: `unavailable`.", + "complexTypes": [ + "TrackingResult" + ], + "slug": "gettrackingauthorizationstatus" + }, + { + "name": "loadRewarded", + "signature": "(options: AdUnitOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "AdUnitOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Start loading a rewarded ad for the ad unit. The native ad object is created on first use and reused for the\nad unit. Resolves once the request is issued; the outcome arrives as a `loaded` or `loadFailed` event.\nLoad the next ad after each show.", + "complexTypes": [ + "AdUnitOptions" + ], + "slug": "loadrewarded" + }, + { + "name": "showRewarded", + "signature": "(options: ShowOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "ShowOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Show a loaded rewarded ad. Resolves after the ad closed (or failed to display) with what happened. The reward\nand close callbacks can arrive in either order on some networks, so the plugin waits up to 1 second after the close\nfor a late reward. Never rejects for \"not ready\": resolves `{ shown: false, rewarded: false, error }` instead.", + "complexTypes": [ + "ShowResult", + "ShowOptions" + ], + "slug": "showrewarded" + }, + { + "name": "loadInterstitial", + "signature": "(options: AdUnitOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "AdUnitOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Start loading an interstitial ad for the ad unit. Works like `loadRewarded()`.", + "complexTypes": [ + "AdUnitOptions" + ], + "slug": "loadinterstitial" + }, + { + "name": "showInterstitial", + "signature": "(options: ShowOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "ShowOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Show a loaded interstitial. Resolves after it closed (or failed to display). Never rejects for \"not ready\".", + "complexTypes": [ + "ShowResult", + "ShowOptions" + ], + "slug": "showinterstitial" + }, + { + "name": "isReady", + "signature": "(options: IsReadyOptions) => Promise", + "parameters": [ + { + "name": "options", + "docs": "", + "type": "IsReadyOptions" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "`isAdReady()` of the native ad object for this ad unit. `false` when the ad unit was never loaded.", + "complexTypes": [ + "IsReadyResult", + "IsReadyOptions" + ], + "slug": "isready" + }, + { + "name": "launchTestSuite", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Open the LevelPlay Integration Test Suite. Requires `initialize({ testSuite: true })` first.\nDevelopment builds only. Rejects on the web.", + "complexTypes": [], + "slug": "launchtestsuite" + }, + { + "name": "validateIntegration", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Write the LevelPlay integration helper report to the native log (Xcode console; Android logcat tag\n`IntegrationHelper`): SDK, adapter and network SDK versions, each `VERIFIED` or not. Development only.", + "complexTypes": [], + "slug": "validateintegration" + }, + { + "name": "addListener", + "signature": "(eventName: 'loaded', listenerFunc: (event: AdEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'loaded'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "An ad finished loading for the ad unit and can be shown.", + "complexTypes": [ + "PluginListenerHandle", + "AdEvent" + ], + "slug": "addlistenerloaded-" + }, + { + "name": "addListener", + "signature": "(eventName: 'loadFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'loadFailed'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdErrorEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Loading failed, for example `509` (no fill). Retry later with a backoff.", + "complexTypes": [ + "PluginListenerHandle", + "AdErrorEvent" + ], + "slug": "addlistenerloadfailed-" + }, + { + "name": "addListener", + "signature": "(eventName: 'displayed', listenerFunc: (event: AdEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'displayed'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "The ad was displayed (impression). `adInfo.revenue` is available here.", + "complexTypes": [ + "PluginListenerHandle", + "AdEvent" + ], + "slug": "addlistenerdisplayed-" + }, + { + "name": "addListener", + "signature": "(eventName: 'displayFailed', listenerFunc: (event: AdErrorEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'displayFailed'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdErrorEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "The ad failed to display. The pending show call resolves with the same error.", + "complexTypes": [ + "PluginListenerHandle", + "AdErrorEvent" + ], + "slug": "addlistenerdisplayfailed-" + }, + { + "name": "addListener", + "signature": "(eventName: 'clicked', listenerFunc: (event: AdEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'clicked'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "The user clicked the ad.", + "complexTypes": [ + "PluginListenerHandle", + "AdEvent" + ], + "slug": "addlistenerclicked-" + }, + { + "name": "addListener", + "signature": "(eventName: 'closed', listenerFunc: (event: AdEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'closed'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "The ad was closed and the app is back in front.", + "complexTypes": [ + "PluginListenerHandle", + "AdEvent" + ], + "slug": "addlistenerclosed-" + }, + { + "name": "addListener", + "signature": "(eventName: 'rewarded', listenerFunc: (event: AdRewardEvent) => void) => Promise", + "parameters": [ + { + "name": "eventName", + "docs": "", + "type": "'rewarded'" + }, + { + "name": "listenerFunc", + "docs": "", + "type": "(event: AdRewardEvent) => void" + } + ], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Rewarded only: the user earned the reward. Can fire before or after `closed`.", + "complexTypes": [ + "PluginListenerHandle", + "AdRewardEvent" + ], + "slug": "addlistenerrewarded-" + }, + { + "name": "removeAllListeners", + "signature": "() => Promise", + "parameters": [], + "returns": "Promise", + "tags": [ + { + "name": "since", + "text": "0.1.0" + } + ], + "docs": "Remove every listener of this plugin.", + "complexTypes": [], + "slug": "removealllisteners" + } + ], + "properties": [] + }, + "interfaces": [ + { + "name": "InitResult", + "slug": "initresult", + "docs": "Result of `initialize()` and `getSdkVersion()`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "sdkVersion", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Native LevelPlay SDK version, for example `9.6.1`. `web` on the web.", + "complexTypes": [], + "type": "string" + } + ] + }, + { + "name": "InitOptions", + "slug": "initoptions", + "docs": "Options for `initialize()`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "appKey", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "LevelPlay app key from the LevelPlay dashboard. Android and iOS apps have different keys.", + "complexTypes": [], + "type": "string" + }, + { + "name": "userId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Optional user id. Needed for server-to-server reward callbacks and the Ad Quality user journey.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "testSuite", + "tags": [ + { + "text": "false", + "name": "default" + }, + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Enable the LevelPlay Integration Test Suite: sets the `is_test_suite=enable` meta data before init.\nCall `launchTestSuite()` after `initialize` resolves. Never ship this enabled.", + "complexTypes": [], + "type": "boolean | undefined" + }, + { + "name": "adaptersDebug", + "tags": [ + { + "text": "false", + "name": "default" + }, + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Turn on debug logs of the mediated ad network adapters (`LevelPlay.setAdaptersDebug(true)`). Development only.", + "complexTypes": [], + "type": "boolean | undefined" + }, + { + "name": "consent", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Privacy signals applied right before init (LevelPlay recommends setting them before the SDK starts).\nSame as calling `setConsent()` first.", + "complexTypes": [ + "ConsentOptions" + ], + "type": "ConsentOptions" + } + ] + }, + { + "name": "ConsentOptions", + "slug": "consentoptions", + "docs": "Privacy signals forwarded to LevelPlay (`LevelPlayPrivacySettings` on Android, `LPMPrivacySettings` on iOS).\nOmitted fields are left untouched.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "gdprConsent", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "GDPR: `true` when the user consented to personalised ads and data processing, `false` when they did not.\nFor users in the EEA, UK and Switzerland pass `false` until a consent management platform (CMP) says otherwise.", + "complexTypes": [], + "type": "boolean | undefined" + }, + { + "name": "ccpaDoNotSell", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "CCPA and other US state privacy laws: `true` when the user opted OUT of the sale or sharing of personal data\n(\"do not sell\"), `false` otherwise.", + "complexTypes": [], + "type": "boolean | undefined" + }, + { + "name": "coppa", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "COPPA: `true` when the user must be treated as a child (child-directed treatment).", + "complexTypes": [], + "type": "boolean | undefined" + } + ] + }, + { + "name": "MetaDataOptions", + "slug": "metadataoptions", + "docs": "Options for `setMetaData()`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "key", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Meta data key, for example `is_deviceid_optout` or a network-specific flag from Unity's docs.", + "complexTypes": [], + "type": "string" + }, + { + "name": "value", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Meta data value, always a string (for example `\"true\"`).", + "complexTypes": [], + "type": "string" + } + ] + }, + { + "name": "TrackingResult", + "slug": "trackingresult", + "docs": "Result of `requestTrackingAuthorization()` and\n`getTrackingAuthorizationStatus()`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "status", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "iOS App Tracking Transparency status. Always `unavailable` on Android and web.", + "complexTypes": [ + "TrackingStatus" + ], + "type": "TrackingStatus" + } + ] + }, + { + "name": "AdUnitOptions", + "slug": "adunitoptions", + "docs": "Identifies one ad unit.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "adUnitId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad unit id from the LevelPlay dashboard (Ad units page). Android and iOS ad units have different ids.", + "complexTypes": [], + "type": "string" + } + ] + }, + { + "name": "ShowResult", + "slug": "showresult", + "docs": "Result of `showRewarded()` and `showInterstitial()`, resolved after the ad\nclosed or failed to display.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "shown", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "The ad was displayed (the `displayed` event fired).", + "complexTypes": [], + "type": "boolean" + }, + { + "name": "rewarded", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Rewarded only: the reward callback fired for this show. Grant the reward only when this is `true`.\nAlways `false` for interstitials.", + "complexTypes": [], + "type": "boolean" + }, + { + "name": "reward", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "The reward, present when `rewarded` is `true`.", + "complexTypes": [ + "Reward" + ], + "type": "Reward" + }, + { + "name": "error", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Present when the ad was not ready (`code: -1`) or failed to display.", + "complexTypes": [ + "AdError" + ], + "type": "AdError" + }, + { + "name": "adInfo", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Info of the displayed ad.", + "complexTypes": [ + "AdInfo" + ], + "type": "AdInfo" + } + ] + }, + { + "name": "Reward", + "slug": "reward", + "docs": "The reward of a rewarded ad, as configured in the LevelPlay dashboard (per ad unit or placement).", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "name", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Name of the reward, for example `Coins`.", + "complexTypes": [], + "type": "string" + }, + { + "name": "amount", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Amount of the reward.", + "complexTypes": [], + "type": "number" + } + ] + }, + { + "name": "AdError", + "slug": "aderror", + "docs": "Error reported by the SDK (load / display failures) or by the plugin.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "code", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "LevelPlay error code, for example `509` (no fill). `-1` is used by the plugin for \"Ad not ready\" and for the web\nstub.", + "complexTypes": [], + "type": "number" + }, + { + "name": "message", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Human readable message.", + "complexTypes": [], + "type": "string" + } + ] + }, + { + "name": "AdInfo", + "slug": "adinfo", + "docs": "Subset of the native `LevelPlayAdInfo` (Android) / `LPMAdInfo` (iOS) that is useful in JavaScript.\nFields the SDK does not report are omitted.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "adId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Unique id of this ad.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "adUnitId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad unit id.", + "complexTypes": [], + "type": "string" + }, + { + "name": "adUnitName", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad unit name from the dashboard.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "adFormat", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad format as reported by the SDK.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "placementName", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Placement name of the show call, when one was used.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "adNetwork", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Name of the mediated network that served the ad.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "instanceName", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Mediation instance name.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "instanceId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Mediation instance id.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "country", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Country code of the impression.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "auctionId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Auction id.", + "complexTypes": [], + "type": "string | undefined" + }, + { + "name": "revenue", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Impression revenue in USD as reported by the SDK (may be absent or 0 before display).", + "complexTypes": [], + "type": "number | undefined" + }, + { + "name": "precision", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Revenue precision as reported by the SDK.", + "complexTypes": [], + "type": "string | undefined" + } + ] + }, + { + "name": "ShowOptions", + "slug": "showoptions", + "docs": "Options for `showRewarded()` and `showInterstitial()`: `adUnitId` (see AdUnitOptions) plus an optional placement.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "placementName", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Optional placement name configured in the LevelPlay dashboard (capping, pacing and reward per placement).\nOmit it to use the default placement.", + "complexTypes": [], + "type": "string | undefined" + } + ] + }, + { + "name": "IsReadyResult", + "slug": "isreadyresult", + "docs": "Result of `isReady()`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "ready", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "`true` when a loaded ad can be shown right now.", + "complexTypes": [], + "type": "boolean" + } + ] + }, + { + "name": "IsReadyOptions", + "slug": "isreadyoptions", + "docs": "Options for `isReady()`: `adUnitId` (see AdUnitOptions) plus the format.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "format", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Format of the ad unit.", + "complexTypes": [ + "AdFormat" + ], + "type": "AdFormat" + } + ] + }, + { + "name": "PluginListenerHandle", + "slug": "pluginlistenerhandle", + "docs": "", + "tags": [], + "methods": [], + "properties": [ + { + "name": "remove", + "tags": [], + "docs": "", + "complexTypes": [], + "type": "() => Promise" + } + ] + }, + { + "name": "AdEvent", + "slug": "adevent", + "docs": "Payload of the `loaded`, `displayed`, `clicked` and `closed` events.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "format", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Format of the ad unit that fired the event.", + "complexTypes": [ + "AdFormat" + ], + "type": "AdFormat" + }, + { + "name": "adUnitId", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad unit that fired the event.", + "complexTypes": [], + "type": "string" + }, + { + "name": "adInfo", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "Ad info, when the SDK provides it (not on `loadFailed`).", + "complexTypes": [ + "AdInfo" + ], + "type": "AdInfo" + } + ] + }, + { + "name": "AdErrorEvent", + "slug": "aderrorevent", + "docs": "Payload of the `loadFailed` and `displayFailed` events: the AdEvent fields plus `error`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "error", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "What went wrong.", + "complexTypes": [ + "AdError" + ], + "type": "AdError" + } + ] + }, + { + "name": "AdRewardEvent", + "slug": "adrewardevent", + "docs": "Payload of the `rewarded` event: the AdEvent fields plus `reward`.", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "methods": [], + "properties": [ + { + "name": "reward", + "tags": [ + { + "text": "0.1.0", + "name": "since" + } + ], + "docs": "The reward earned.", + "complexTypes": [ + "Reward" + ], + "type": "Reward" + } + ] + } + ], + "enums": [], + "typeAliases": [ + { + "name": "TrackingStatus", + "slug": "trackingstatus", + "docs": "iOS App Tracking Transparency status. `unavailable` on Android, on the web and on unknown future iOS values.", + "types": [ + { + "text": "'authorized'", + "complexTypes": [] + }, + { + "text": "'denied'", + "complexTypes": [] + }, + { + "text": "'restricted'", + "complexTypes": [] + }, + { + "text": "'notDetermined'", + "complexTypes": [] + }, + { + "text": "'unavailable'", + "complexTypes": [] + } + ] + }, + { + "name": "AdFormat", + "slug": "adformat", + "docs": "Full-screen ad formats supported by this plugin. Banners and native ads are intentionally not exposed.", + "types": [ + { + "text": "'rewarded'", + "complexTypes": [] + }, + { + "text": "'interstitial'", + "complexTypes": [] + } + ] + } + ], + "pluginConfigs": [] +} \ No newline at end of file diff --git a/package.json b/package.json index c6a275d..c3f9535 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "capacitor-levelplay", - "version": "0.1.0", - "description": "Capacitor 8 plugin for Unity LevelPlay (ironSource) rewarded and interstitial ads. Swift Package Manager first, ad-unit API.", + "version": "0.2.0", + "description": "Capacitor 8 plugin for Unity LevelPlay (ironSource) rewarded and interstitial ads on Android and iOS: ad-unit API, Swift Package Manager first, ATT and GDPR / CCPA / COPPA consent.", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", "types": "dist/esm/index.d.ts", @@ -11,36 +11,62 @@ "android/build.gradle", "android/proguard-rules.pro", "dist/", - "ios/Sources", + "ios/Sources/", "Package.swift", - "CapacitorLevelplay.podspec" + "CapacitorLevelplay.podspec", + "CHANGELOG.md" ], - "author": "VOX Games", + "author": { + "name": "VOX Games", + "url": "https://vox.games" + }, "license": "MIT", + "homepage": "https://git.crt.fyi/CRT/capacitor-levelplay#readme", + "bugs": { + "url": "https://git.crt.fyi/CRT/capacitor-levelplay/issues" + }, "repository": { "type": "git", - "url": "https://git.crt.fyi/CRT/capacitor-levelplay.git" + "url": "git+https://git.crt.fyi/CRT/capacitor-levelplay.git" }, "keywords": [ "capacitor", + "capacitor-plugin", + "capacitor8", "plugin", "native", "levelplay", + "unity-levelplay", "ironsource", "unity", + "unity-ads", "ads", + "mediation", "rewarded", - "interstitial" + "rewarded-video", + "interstitial", + "ios", + "android", + "swift-package-manager" ], + "engines": { + "node": ">=22" + }, "scripts": { - "build": "rm -rf dist && tsc && rollup -c rollup.config.mjs", + "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs", + "clean": "rm -rf dist", + "docgen": "docgen --api LevelPlayPlugin --output-readme README.md --output-json dist/docs.json", "typecheck": "tsc --noEmit", + "verify": "bun run typecheck && bun run build && bun run verify:ios && bun run verify:android", "verify:ios": "xcodebuild build -scheme CapacitorLevelplay -destination 'generic/platform=iOS Simulator'", + "verify:android": "cd android && ./gradlew clean build test && cd ..", "verify:web": "bun run build", "prepublishOnly": "bun run build" }, "devDependencies": { + "@capacitor/android": "^8.0.0", "@capacitor/core": "^8.0.0", + "@capacitor/docgen": "^0.3.1", "rollup": "^4.53.3", "typescript": "^5.9.3" },