diff --git a/.github/workflows/build+test+deploy.yml b/.github/workflows/build+test+deploy.yml
index 70a4ad24..01f42e1f 100644
--- a/.github/workflows/build+test+deploy.yml
+++ b/.github/workflows/build+test+deploy.yml
@@ -107,7 +107,7 @@ jobs:
with:
payload: |
{
- "text": "Please create a new Android Release! https://github.com/superwall-me/Superwall-Android/releases/new?tag=${{steps.version.outputs.prop}}&prerelease=${{steps.prerelease.outputs.status}}"
+ "text": "Please create a new Android Release! https://github.com/superwall/Superwall-Android/releases/new?tag=${{steps.version.outputs.prop}}&prerelease=${{steps.prerelease.outputs.status}}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml
index 30a91f26..80a19bc3 100644
--- a/.github/workflows/on-release.yml
+++ b/.github/workflows/on-release.yml
@@ -12,5 +12,5 @@ jobs:
uses: peter-evans/repository-dispatch@98b1133981c5060126325c279a8840c1711a9fe0
with:
token: ${{ secrets.MAIN_REPO_PAT }}
- repository: superwall-me/paywall-next
+ repository: superwall/paywall-next
event-type: android-release
diff --git a/.gitignore b/.gitignore
index 7ba590e1..f6fc6f91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,13 @@
-*.iml
-.gradle
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
-.DS_Store
-/build
-/captures
-.externalNativeBuild
-.cxx
-local.properties
-.idea/*
+**/*.iml
+**/.gradle
+**/local.properties
+**/.DS_Store
+**/build
+**/captures
+**/.externalNativeBuild
+**/.cxx
+**/local.properties
+**/.idea/
private_key.pepk
upload-keystore.jks
.env
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39037164..599ca504 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,21 @@
# CHANGELOG
-The changelog for `Superwall`. Also see the [releases](https://github.com/superwall-me/Superwall-Android/releases) on GitHub.
+The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.
+
+## 1.0.3-beta.1
+
+### Fixes
+
+- SW-2732: User attributes weren't being sent on app open until identify was called. Now they are
+sent every time there's a new session.
+- SW-2733: Fixes issue where the spinner would still show on a paywall if a user had previously
+ purchased on it.
+- SW-2744: Fixes issue where using the back button to dismiss a paywall presented via `getPaywall`
+would call `didFinish` in the `PaywallViewControllerDelegate` with the incorrect values.
+- Fixes issue where an invalid paywall background color would prevent the paywall from opening. If
+this happens, it will now default to white.
+- SW-2748: Exposes `viewWillAppear`, `viewDidAppear`, `viewWillDisappear` and `viewDidDisappear`
+methods of `PaywallViewController` which you must call when using `getPaywall`.
## 1.0.2
diff --git a/README.md b/README.md
index 17701ac7..30139117 100644
--- a/README.md
+++ b/README.md
@@ -12,14 +12,14 @@
-
+
-
+
@@ -42,7 +42,7 @@
✏️ | A/B Testing - automatically calculate metrics for different paywalls
📝 | [Online documentation](https://superwall.com/docs/android-beta) up to date
🔀 | [Integrations](https://superwall.com/docs/android-beta) - over a dozen integrations to easily send conversion data where you need it
-💯 | Well maintained - [frequent releases](https://github.com/superwall-me/Superwall-Android/releases)
+💯 | Well maintained - [frequent releases](https://github.com/superwall/Superwall-Android/releases)
📮 | Great support - email a founder: jake@superwall.com
## Installation
@@ -55,7 +55,7 @@ The preferred installation method is with [Gradle](https://superwall.com/docs/in
- Open **settings.gradle**
- Add `maven { url 'https://mvn.superwall.com/release' }` to your `repositories { ... }`
-- Add `implementation "com.superwall.sdk:superwall-android:"` [latest version](https://github.com/superwall-me/Superwall-Android/releases)
+- Add `implementation "com.superwall.sdk:superwall-android:"` [latest version](https://github.com/superwall/Superwall-Android/releases)
- Make sure you press `Sync Now`
- Edit your **AndroidManifest.xml** by adding:
```xml
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 9e2cd5bd..e310e3a2 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -10,8 +10,8 @@ android {
defaultConfig {
applicationId = "com.superwall.superapp"
- minSdkVersion(26)
- targetSdkVersion(33)
+ minSdk = 26
+ targetSdk = 34
versionCode = 2
versionName = "1.0.0"
@@ -20,7 +20,7 @@ android {
}
buildTypes {
- getByName("release") {
+ release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
diff --git a/app/src/main/java/com/superwall/superapp/ComposeActivity.kt b/app/src/main/java/com/superwall/superapp/ComposeActivity.kt
index ae9d179c..0dc40d0d 100644
--- a/app/src/main/java/com/superwall/superapp/ComposeActivity.kt
+++ b/app/src/main/java/com/superwall/superapp/ComposeActivity.kt
@@ -103,7 +103,7 @@ fun ComposeActivityContent(@PreviewParameter(PreviewPaywallDelegateProvider::cla
@Composable
fun TabContent0(paywallOverrides: PaywallOverrides?, delegate: PaywallViewControllerDelegate) {
PaywallComposable(
- event = "another_paywall",
+ event = "no_products",
params = mapOf("key" to "value"),
paywallOverrides = paywallOverrides,
delegate = delegate
diff --git a/app/src/main/java/com/superwall/superapp/MainApplication.kt b/app/src/main/java/com/superwall/superapp/MainApplication.kt
index 48e94b59..67af64f4 100644
--- a/app/src/main/java/com/superwall/superapp/MainApplication.kt
+++ b/app/src/main/java/com/superwall/superapp/MainApplication.kt
@@ -35,16 +35,16 @@ class MainApplication : android.app.Application(), SuperwallDelegate {
fun configureWithAutomaticInitialization() {
Superwall.configure(
this,
- CONSTANT_API_KEY,
+ CONSTANT_API_KEY
)
Superwall.instance.delegate = this
// Make sure we enable the game controller
- Superwall.instance.options.isGameControllerEnabled = true
+ // Superwall.instance.options.isGameControllerEnabled = true
}
fun configureWithRevenueCatInitialization() {
- val purchaseController = RevenueCatPurchaseController(this)
+ val purchaseController = RevenueCatPurchaseController(this)
Superwall.configure(
this,
@@ -54,7 +54,7 @@ class MainApplication : android.app.Application(), SuperwallDelegate {
Superwall.instance.delegate = this
// Make sure we enable the game controller
- Superwall.instance.options.isGameControllerEnabled = true
+ // Superwall.instance.options.isGameControllerEnabled = true
purchaseController.syncSubscriptionStatus()
}
diff --git a/example/.gitignore b/example/.gitignore
new file mode 100644
index 00000000..aa724b77
--- /dev/null
+++ b/example/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties
diff --git a/app/.gitignore b/example/app/.gitignore
similarity index 100%
rename from app/.gitignore
rename to example/app/.gitignore
diff --git a/example/app/build.gradle.kts b/example/app/build.gradle.kts
new file mode 100644
index 00000000..9b9dc779
--- /dev/null
+++ b/example/app/build.gradle.kts
@@ -0,0 +1,72 @@
+plugins {
+ id("com.android.application")
+ id("org.jetbrains.kotlin.android")
+}
+
+android {
+ namespace = "com.superwall.exampleapp"
+ compileSdk = 34
+
+ defaultConfig {
+ applicationId = "com.superwall.superapp"
+ minSdk = 26
+ targetSdk = 34
+ versionCode = 1
+ versionName = "1.0.0"
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ vectorDrawables {
+ useSupportLibrary = true
+ }
+ }
+
+ buildTypes {
+ getByName("release") {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+ buildFeatures {
+ compose = true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion = "1.4.7"
+ }
+ packagingOptions {
+ resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
+ }
+}
+
+dependencies {
+ implementation(project(":superwall"))
+
+ // Billing
+ implementation(libs.billing)
+ implementation(libs.revenue.cat)
+
+ // Compose
+ implementation(platform(libs.compose.bom))
+ implementation(libs.activity.compose)
+ implementation(libs.ui)
+ implementation(libs.ui.graphics)
+ implementation(libs.ui.tooling.preview)
+ implementation(libs.material3)
+
+ // Core
+ implementation(libs.core)
+ implementation(libs.appcompat)
+ implementation(libs.material)
+ implementation(libs.constraintlayout)
+ implementation(libs.core.ktx)
+ implementation(libs.lifecycle.runtime.ktx)
+}
\ No newline at end of file
diff --git a/example/app/proguard-rules.pro b/example/app/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/example/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/example/app/src/main/AndroidManifest.xml b/example/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..b53db63e
--- /dev/null
+++ b/example/app/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/java/com/superwall/exampleapp/HomeActivity.kt b/example/app/src/main/java/com/superwall/exampleapp/HomeActivity.kt
new file mode 100644
index 00000000..254c8575
--- /dev/null
+++ b/example/app/src/main/java/com/superwall/exampleapp/HomeActivity.kt
@@ -0,0 +1,202 @@
+package com.superwall.exampleapp
+
+import android.app.AlertDialog
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Button
+import androidx.compose.material3.Divider
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.collectAsState
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.core.view.WindowCompat
+import com.superwall.exampleapp.ui.theme.SuperwallExampleAppTheme
+import com.superwall.sdk.Superwall
+import com.superwall.sdk.delegate.SubscriptionStatus
+import com.superwall.sdk.misc.AlertControllerFactory
+import com.superwall.sdk.paywall.presentation.PaywallPresentationHandler
+import com.superwall.sdk.paywall.presentation.internal.state.PaywallSkippedReason
+import com.superwall.sdk.paywall.presentation.register
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+class HomeActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ WindowCompat.setDecorFitsSystemWindows(window, false)
+
+ setContent() {
+ val subscriptionStatus by Superwall.instance.subscriptionStatus.collectAsState()
+ SuperwallExampleAppTheme {
+ HomeScreen(
+ subscriptionStatus = subscriptionStatus,
+ onLogOutClicked = {
+ finish()
+ }
+ )
+ }
+ }
+ }
+}
+
+@Composable
+fun HomeScreen(
+ subscriptionStatus: SubscriptionStatus,
+ onLogOutClicked: () -> Unit
+) {
+ val context = LocalContext.current
+ val subscriptionText = when (subscriptionStatus) {
+ SubscriptionStatus.UNKNOWN -> "Loading subscription status."
+ SubscriptionStatus.ACTIVE -> "You currently have an active subscription. Therefore, the " +
+ "paywall will never show. For the purposes of this app, delete and reinstall the " +
+ "app to clear subscriptions."
+
+ SubscriptionStatus.INACTIVE -> "You do not have an active subscription so the paywall will " +
+ "show when clicking the button."
+ }
+
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(16.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.SpaceBetween
+ ) {
+ Text(
+ text = "Presenting a Paywall",
+ style = MaterialTheme.typography.headlineSmall,
+ textAlign = TextAlign.Center,
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(top = 50.dp)
+ )
+ Column(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(
+ text = "The Launch Feature button below registers an event \"campaign_trigger\".\n\n" +
+ "This event has been added to a campaign on the Superwall dashboard.\n\n" +
+ "When this event is registered, the rules in the campaign are evaluated.\n\n" +
+ "The rules match and cause a paywall to show.",
+ textAlign = TextAlign.Center
+ )
+ Spacer(modifier = Modifier.height(16.dp))
+ Divider()
+ Spacer(modifier = Modifier.height(16.dp))
+ Text(
+ text = subscriptionText,
+ textAlign = TextAlign.Center
+ )
+ }
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Button(
+ onClick = {
+ val handler = PaywallPresentationHandler()
+ handler.onDismiss { paywallInfo ->
+ println("The paywall dismissed. PaywallInfo: $paywallInfo")
+ }
+ handler.onPresent { paywallInfo ->
+ println("The paywall presented. PaywallInfo: $paywallInfo")
+ }
+ handler.onError { error ->
+ println("The paywall presentation failed with error $error")
+ }
+ handler.onSkip { reason ->
+ when (reason) {
+ is PaywallSkippedReason.EventNotFound -> {
+ print("Paywall not shown because this event isn't part of a campaign.")
+ }
+ is PaywallSkippedReason.Holdout -> {
+ print("Paywall not shown because user is in a holdout group in " +
+ "Experiment: ${reason.experiment.id}")
+ }
+ is PaywallSkippedReason.NoRuleMatch -> {
+ print("Paywall not shown because user doesn't match any rules.")
+ }
+ is PaywallSkippedReason.UserIsSubscribed -> {
+ print("Paywall not shown because user is subscribed.")
+ }
+ }
+ }
+
+ Superwall.instance.register(event = "campaign_trigger", handler = handler) {
+ // code in here can be remotely configured to execute. Either
+ // (1) always after presentation or
+ // (2) only if the user pays
+ // code is always executed if no paywall is configured to show
+ val builder = AlertDialog.Builder(context)
+ .setTitle("Feature Launched")
+ .setMessage("The feature block was called")
+
+ builder.setPositiveButton("Ok") { _, _ -> }
+
+ val alertDialog = builder.create()
+ alertDialog.show()
+ }
+ },
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(min = 50.dp)
+ .padding(top = 8.dp)
+ ) {
+ Text(
+ text = "Launch Feature",
+ color = MaterialTheme.colorScheme.onPrimary,
+ style = TextStyle(
+ fontWeight = FontWeight.Bold,
+ fontSize = 18.sp
+ )
+ )
+ }
+ Spacer(modifier = Modifier.height(8.dp))
+ Button(
+ onClick = {
+ Superwall.instance.reset()
+ onLogOutClicked()
+ },
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(min = 50.dp)
+ .padding(vertical = 8.dp)
+ ) {
+ Text(
+ text = "Log Out",
+ color = MaterialTheme.colorScheme.onPrimary,
+ style = TextStyle(
+ fontWeight = FontWeight.Bold,
+ fontSize = 18.sp
+ )
+ )
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/example/app/src/main/java/com/superwall/exampleapp/MainActivity.kt b/example/app/src/main/java/com/superwall/exampleapp/MainActivity.kt
new file mode 100644
index 00000000..b465eebe
--- /dev/null
+++ b/example/app/src/main/java/com/superwall/exampleapp/MainActivity.kt
@@ -0,0 +1,168 @@
+package com.superwall.exampleapp
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.BasicTextField
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.material3.Button
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.ExperimentalComposeUiApi
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.core.view.WindowCompat
+import com.superwall.exampleapp.ui.theme.SuperwallExampleAppTheme
+import com.superwall.sdk.Superwall
+import com.superwall.sdk.identity.identify
+import com.superwall.sdk.identity.setUserAttributes
+
+class MainActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ Superwall.configure(
+ applicationContext = this,
+ apiKey = "pk_3b18882b1683318b710c741f371f40f54e357c6f0baff1f4"
+ )
+
+ WindowCompat.setDecorFitsSystemWindows(window, false)
+
+ setContent {
+ SuperwallExampleAppTheme {
+ WelcomeScreen()
+ }
+ }
+ }
+}
+
+@OptIn(ExperimentalComposeUiApi::class)
+@Composable
+fun WelcomeScreen() {
+ val keyboardController = LocalSoftwareKeyboardController.current
+ var isFocused by remember { mutableStateOf(false) }
+ var name by remember { mutableStateOf("") }
+ val context = LocalContext.current
+
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(bottom = 20.dp),
+ contentAlignment = Alignment.Center
+ ) {
+ Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(16.dp)) {
+ Spacer(modifier = Modifier.weight(1f))
+
+ Text(
+ text = "Welcome! Enter your name to get started. Your name will be added to the Paywall user attributes, which can then be accessed and displayed within your paywall.",
+ color = MaterialTheme.colorScheme.onBackground,
+ textAlign = TextAlign.Center
+ )
+
+ BasicTextField(
+ value = name,
+ onValueChange = { name = it },
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(vertical = 26.dp)
+ .heightIn(max = 50.dp)
+ .background(color = Color.White, shape = RoundedCornerShape(25.dp))
+ .onFocusChanged { focusState ->
+ isFocused = focusState.isFocused
+ },
+ keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
+ keyboardActions = KeyboardActions(onDone = {
+ keyboardController?.hide()
+ startHomeActivity(context, name)
+ }),
+ textStyle = TextStyle(
+ color = Color.Black,
+ textAlign = TextAlign.Start
+ ),
+ singleLine = true,
+ decorationBox = { innerTextField ->
+ Row(
+ modifier = Modifier
+ .fillMaxHeight()
+ .padding(horizontal = 16.dp), // Apply horizontal padding to the Row
+ verticalAlignment = Alignment.CenterVertically // Align text to the center vertically,
+ ) {
+ if (name.isEmpty() && !isFocused) {
+ Text(
+ "Enter your name",
+ style = TextStyle(color = Color.Gray)
+ )
+ }
+ innerTextField() // The inner text field will inherit the Row's padding
+ }
+ }
+ )
+ Spacer(modifier = Modifier.weight(1f))
+
+ Button(
+ onClick = { startHomeActivity(context, name) },
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(min = 50.dp)
+ .padding(vertical = 8.dp)
+ ) {
+ Text(
+ text = "Log In",
+ color = MaterialTheme.colorScheme.onPrimary,
+ style = TextStyle(
+ fontWeight = FontWeight.Bold,
+ fontSize = 18.sp
+ )
+ )
+ }
+ }
+ }
+ }
+}
+
+fun startHomeActivity(context: Context, name: String) {
+ if (name.isNotBlank()) {
+ Superwall.instance.setUserAttributes(mapOf(
+ "firstName" to name
+ ))
+ }
+
+ Superwall.instance.identify(userId = "abc")
+
+ val intent = Intent(context, HomeActivity::class.java)
+ context.startActivity(intent)
+}
\ No newline at end of file
diff --git a/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Color.kt b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Color.kt
new file mode 100644
index 00000000..b9847da8
--- /dev/null
+++ b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Color.kt
@@ -0,0 +1,11 @@
+package com.superwall.exampleapp.ui.theme
+
+import androidx.compose.ui.graphics.Color
+
+val Purple80 = Color(0xFFD0BCFF)
+val PurpleGrey80 = Color(0xFFCCC2DC)
+val Pink80 = Color(0xFFEFB8C8)
+
+val Purple40 = Color(0xFF6650a4)
+val PurpleGrey40 = Color(0xFF625b71)
+val Pink40 = Color(0xFF7D5260)
\ No newline at end of file
diff --git a/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Theme.kt b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Theme.kt
new file mode 100644
index 00000000..fe30d3d0
--- /dev/null
+++ b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Theme.kt
@@ -0,0 +1,71 @@
+package com.superwall.exampleapp.ui.theme
+
+import android.app.Activity
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.SideEffect
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.toArgb
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
+import androidx.core.view.WindowCompat
+
+private val DarkColorScheme = darkColorScheme(
+ primary = Color(0xFF9AFBF0),
+ background = Color.Black,
+ surface = Color.Black
+)
+
+private val LightColorScheme = lightColorScheme(
+ primary = Color(0xFF9AFBF0),
+ background = Color.Black,
+ surface = Color.Black
+
+ /* Other default colors to override
+ background = Color(0xFFFFFBFE),
+ surface = Color(0xFFFFFBFE),
+ onPrimary = Color.White,
+ onSecondary = Color.White,
+ onTertiary = Color.White,
+ onBackground = Color(0xFF1C1B1F),
+ onSurface = Color(0xFF1C1B1F),
+ */
+)
+
+@Composable
+fun SuperwallExampleAppTheme(
+ darkTheme: Boolean = true,
+ // Dynamic color is available on Android 12+
+ dynamicColor: Boolean = false,
+ content: @Composable () -> Unit
+) {
+ val colorScheme = when {
+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
+ val context = LocalContext.current
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ }
+
+ darkTheme -> DarkColorScheme
+ else -> LightColorScheme
+ }
+ val view = LocalView.current
+ if (!view.isInEditMode) {
+ SideEffect {
+ val window = (view.context as Activity).window
+ window.statusBarColor = colorScheme.background.toArgb()
+ WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = false
+ }
+ }
+
+ MaterialTheme(
+ colorScheme = colorScheme,
+ typography = Typography,
+ content = content
+ )
+}
\ No newline at end of file
diff --git a/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Type.kt b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Type.kt
new file mode 100644
index 00000000..c9245aef
--- /dev/null
+++ b/example/app/src/main/java/com/superwall/exampleapp/ui/theme/Type.kt
@@ -0,0 +1,34 @@
+package com.superwall.exampleapp.ui.theme
+
+import androidx.compose.material3.Typography
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+
+// Set of Material typography styles to start with
+val Typography = Typography(
+ bodyLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ lineHeight = 24.sp,
+ letterSpacing = 0.5.sp
+ )
+ /* Other default text styles to override
+ titleLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 22.sp,
+ lineHeight = 28.sp,
+ letterSpacing = 0.sp
+ ),
+ labelSmall = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Medium,
+ fontSize = 11.sp,
+ lineHeight = 16.sp,
+ letterSpacing = 0.5.sp
+ )
+ */
+)
\ No newline at end of file
diff --git a/example/app/src/main/res/drawable/ic_launcher_background.xml b/example/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..07d5da9c
--- /dev/null
+++ b/example/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/app/src/main/res/drawable/ic_launcher_foreground.xml b/example/app/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 00000000..2b068d11
--- /dev/null
+++ b/example/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/example/app/src/main/res/mipmap-anydpi/ic_launcher.xml
new file mode 100644
index 00000000..6f3b755b
--- /dev/null
+++ b/example/app/src/main/res/mipmap-anydpi/ic_launcher.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/example/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
new file mode 100644
index 00000000..6f3b755b
--- /dev/null
+++ b/example/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/example/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 00000000..c209e78e
Binary files /dev/null and b/example/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/example/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/example/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..b2dfe3d1
Binary files /dev/null and b/example/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/example/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/example/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 00000000..4f0f1d64
Binary files /dev/null and b/example/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/example/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/example/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..62b611da
Binary files /dev/null and b/example/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/example/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/example/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 00000000..948a3070
Binary files /dev/null and b/example/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/example/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/example/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..1b9a6956
Binary files /dev/null and b/example/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/example/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/example/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..28d4b77f
Binary files /dev/null and b/example/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/example/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/example/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9287f508
Binary files /dev/null and b/example/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..aa7d6427
Binary files /dev/null and b/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9126ae37
Binary files /dev/null and b/example/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/example/app/src/main/res/values/colors.xml b/example/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..f8c6127d
--- /dev/null
+++ b/example/app/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/example/app/src/main/res/values/strings.xml b/example/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..e78b8998
--- /dev/null
+++ b/example/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Superwall Example App
+
\ No newline at end of file
diff --git a/example/app/src/main/res/values/themes.xml b/example/app/src/main/res/values/themes.xml
new file mode 100644
index 00000000..efcc5158
--- /dev/null
+++ b/example/app/src/main/res/values/themes.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/res/xml/backup_rules.xml b/example/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 00000000..fa0f996d
--- /dev/null
+++ b/example/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/example/app/src/main/res/xml/data_extraction_rules.xml b/example/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 00000000..9ee9997b
--- /dev/null
+++ b/example/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/build.gradle.kts b/example/build.gradle.kts
new file mode 100644
index 00000000..013058de
--- /dev/null
+++ b/example/build.gradle.kts
@@ -0,0 +1,7 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
+plugins {
+ alias(libs.plugins.androidApplication) apply false
+ alias(libs.plugins.kotlinAndroid) apply false
+}
+true
\ No newline at end of file
diff --git a/example/gradle.properties b/example/gradle.properties
new file mode 100644
index 00000000..3c5031eb
--- /dev/null
+++ b/example/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/example/gradle/libs.versions.toml b/example/gradle/libs.versions.toml
new file mode 100644
index 00000000..057ad4cc
--- /dev/null
+++ b/example/gradle/libs.versions.toml
@@ -0,0 +1,78 @@
+[versions]
+billing_version = "6.1.0"
+browser_version = "1.5.0"
+gradle_plugin_version = "8.3.0"
+mockk = "1.13.8"
+revenue_cat_version = "7.7.1"
+compose_version = "2022.10.00"
+kotlinx_serialization_json_version = "1.5.1"
+gson_version = "2.8.5"
+activity_compose_version = "1.5.1"
+core_version = "1.6.0"
+appcompat_version = "1.6.1"
+material_version = "1.8.0"
+constraintlayout_version = "2.1.4"
+core_ktx_version = "1.6.0"
+lifecycle_runtime_ktx_version = "2.3.1"
+junit_version = "4.13.2"
+kotlinx_coroutines_test_version = "1.7.1"
+test_ext_junit_version = "1.1.5"
+espresso_core_version = "3.5.1"
+test_runner_version = "1.4.0"
+test_rules_version = "1.4.0"
+kotlin = "1.8.21"
+kotlinx_coroutines_core_version = "1.7.1"
+mockk_version = "1.12.8"
+
+
+[libraries]
+
+# Billing
+billing = { module = "com.android.billingclient:billing", version.ref = "billing_version" }
+revenue_cat = { module = "com.revenuecat.purchases:purchases", version.ref = "revenue_cat_version" }
+
+# Browser
+browser = { module = "androidx.browser:browser", version.ref = "browser_version" }
+
+# Compose
+compose_bom = { module = "androidx.compose:compose-bom", version.ref = "compose_version" }
+activity_compose = { module = "androidx.activity:activity-compose", version.ref = "activity_compose_version" }
+ui = { module = "androidx.compose.ui:ui" }
+ui_graphics = { module = "androidx.compose.ui:ui-graphics" }
+ui_tooling_preview = { module = "androidx.compose.ui:ui-tooling-preview" }
+material3 = { module = "androidx.compose.material3:material3" }
+
+# Core
+core = { module = "androidx.core:core", version.ref = "core_version" }
+appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat_version" }
+material = { module = "com.google.android.material:material", version.ref = "material_version" }
+constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout_version" }
+core_ktx = { module = "androidx.core:core-ktx", version.ref = "core_ktx_version" }
+lifecycle_runtime_ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle_runtime_ktx_version" }
+
+# Coroutines
+kotlinx_coroutines_core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx_coroutines_core_version" }
+
+# Serialization
+kotlinx_serialization_json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx_serialization_json_version" }
+gson = { module = "com.google.code.gson:gson", version.ref = "gson_version" }
+
+# Test
+junit = { module = "junit:junit", version.ref = "junit_version" }
+kotlinx_coroutines_test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx_coroutines_test_version" }
+mockk = { module = "io.mockk:mockk", version.ref = "mockk_version" }
+
+# Test (Android)
+test_ext_junit = { module = "androidx.test.ext:junit", version.ref = "test_ext_junit_version" }
+espresso_core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso_core_version" }
+test_runner = { module = "androidx.test:runner", version.ref = "test_runner_version" }
+test_rules = { module = "androidx.test:rules", version.ref = "test_rules_version" }
+ui_test_junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
+
+# Debug
+ui_tooling = { module = "androidx.compose.ui:ui-tooling" }
+ui_test_manifest = { module = "androidx.compose.ui:ui-test-manifest" }
+
+[plugins]
+androidApplication = { id = "com.android.application", version.ref = "gradle_plugin_version" }
+kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
\ No newline at end of file
diff --git a/example/gradle/wrapper/gradle-wrapper.jar b/example/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..e708b1c0
Binary files /dev/null and b/example/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/example/gradle/wrapper/gradle-wrapper.properties b/example/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..7ce876f3
--- /dev/null
+++ b/example/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Mar 13 15:59:33 EDT 2024
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/example/gradlew b/example/gradlew
new file mode 100755
index 00000000..4f906e0c
--- /dev/null
+++ b/example/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/example/gradlew.bat b/example/gradlew.bat
new file mode 100644
index 00000000..ac1b06f9
--- /dev/null
+++ b/example/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/example/settings.gradle.kts b/example/settings.gradle.kts
new file mode 100644
index 00000000..fce6ba1a
--- /dev/null
+++ b/example/settings.gradle.kts
@@ -0,0 +1,21 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ maven { url = uri("https://mvn.superwall.com/release") }
+ }
+}
+
+rootProject.name = "Superwall Example App"
+include(":app")
+
+include(":superwall")
+project(":superwall").projectDir = file("../superwall")
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 1f5d90d0..e7d84a1a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -16,3 +16,5 @@ dependencyResolutionManagement {
rootProject.name = "My Application"
include ':app'
include ':superwall'
+include 'example:app'
+project(':example:app').projectDir = new File('example/app')
\ No newline at end of file
diff --git a/superwall/build.gradle.kts b/superwall/build.gradle.kts
index 6597fee0..8988867d 100644
--- a/superwall/build.gradle.kts
+++ b/superwall/build.gradle.kts
@@ -19,7 +19,7 @@ plugins {
id("maven-publish")
}
-version = "1.0.2"
+version = "1.0.3-beta.1"
android {
compileSdk = 33
@@ -127,7 +127,6 @@ tasks.register("generateBuildInfo") {
}
}
-
dependencies {
implementation("androidx.work:work-runtime-ktx:2.8.1")
implementation("androidx.lifecycle:lifecycle-process:2.5.0")
diff --git a/superwall/src/main/java/com/superwall/sdk/Superwall.kt b/superwall/src/main/java/com/superwall/sdk/Superwall.kt
index 20e4ba14..31fb8c83 100644
--- a/superwall/src/main/java/com/superwall/sdk/Superwall.kt
+++ b/superwall/src/main/java/com/superwall/sdk/Superwall.kt
@@ -37,7 +37,6 @@ import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.take
import java.util.*
-import java.util.concurrent.Executors
class Superwall(
internal var context: Context,
diff --git a/superwall/src/main/java/com/superwall/sdk/analytics/session/AppSessionManager.kt b/superwall/src/main/java/com/superwall/sdk/analytics/session/AppSessionManager.kt
index 9f7bdf19..95f5bb01 100644
--- a/superwall/src/main/java/com/superwall/sdk/analytics/session/AppSessionManager.kt
+++ b/superwall/src/main/java/com/superwall/sdk/analytics/session/AppSessionManager.kt
@@ -9,6 +9,7 @@ import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent
import com.superwall.sdk.config.ConfigManager
import com.superwall.sdk.config.models.getConfig
import com.superwall.sdk.dependencies.DeviceHelperFactory
+import com.superwall.sdk.dependencies.UserAttributesEventFactory
import com.superwall.sdk.storage.Storage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -25,9 +26,9 @@ class AppSessionManager(
private val context: Context,
private val configManager: ConfigManager,
private val storage: Storage,
- private val delegate: AppSessionManager.Factory
+ private val delegate: Factory
) : DefaultLifecycleObserver {
- interface Factory: AppManagerDelegate, DeviceHelperFactory {}
+ interface Factory: AppManagerDelegate, DeviceHelperFactory, UserAttributesEventFactory {}
var appSessionTimeout: Long? = null
@@ -102,11 +103,12 @@ class AppSessionManager(
if (didStartNewSession) {
appSession = AppSession()
CoroutineScope(Dispatchers.IO).launch {
- val attributes = delegate.makeSessionDeviceAttributes()
+ val deviceAttributes = delegate.makeSessionDeviceAttributes()
+ val userAttributes = delegate.makeUserAttributesEvent()
+
Superwall.instance.track(InternalSuperwallEvent.SessionStart())
- Superwall.instance.track(InternalSuperwallEvent.DeviceAttributes(
- deviceAttributes = attributes
- ))
+ Superwall.instance.track(InternalSuperwallEvent.DeviceAttributes(deviceAttributes))
+ Superwall.instance.track(userAttributes)
}
} else {
appSession.endAt = null
diff --git a/superwall/src/main/java/com/superwall/sdk/composable/PaywallComposable.kt b/superwall/src/main/java/com/superwall/sdk/composable/PaywallComposable.kt
index 99490ba5..f070a36c 100644
--- a/superwall/src/main/java/com/superwall/sdk/composable/PaywallComposable.kt
+++ b/superwall/src/main/java/com/superwall/sdk/composable/PaywallComposable.kt
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -18,6 +19,9 @@ import com.superwall.sdk.paywall.presentation.get_paywall.getPaywall
import com.superwall.sdk.paywall.presentation.internal.request.PaywallOverrides
import com.superwall.sdk.paywall.vc.PaywallViewController
import com.superwall.sdk.paywall.vc.delegate.PaywallViewControllerDelegate
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
@Composable
fun PaywallComposable(
@@ -48,6 +52,7 @@ fun PaywallComposable(
LaunchedEffect(Unit) {
try {
val newView = Superwall.instance.getPaywall(event, params, paywallOverrides, delegate)
+ newView.viewWillAppear()
viewState.value = newView
} catch (e: Throwable) {
errorState.value = e
@@ -56,8 +61,17 @@ fun PaywallComposable(
when {
viewState.value != null -> {
- // If a paywall is returned, it'll be provided here
viewState.value?.let { viewToRender ->
+ DisposableEffect(viewToRender) {
+ viewToRender.viewDidAppear()
+
+ onDispose {
+ viewToRender.viewWillDisappear()
+ CoroutineScope(Dispatchers.IO).launch {
+ viewToRender.viewDidDisappear()
+ }
+ }
+ }
AndroidView(
factory = { context ->
viewToRender
@@ -72,5 +86,4 @@ fun PaywallComposable(
loadingComposable()
}
}
-}
-
+}
\ No newline at end of file
diff --git a/superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt b/superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt
index 6f6a048d..46301f6c 100644
--- a/superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt
+++ b/superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt
@@ -331,6 +331,13 @@ class DependencyContainer(
return HashMap(attributes)
}
+ override fun makeUserAttributesEvent(): InternalSuperwallEvent.Attributes {
+ return InternalSuperwallEvent.Attributes(
+ appInstalledAtString = deviceHelper.appInstalledAtString,
+ customParameters = HashMap(identityManager.userAttributes)
+ )
+ }
+
override fun makeHasExternalPurchaseController(): Boolean {
return storeKitManager.purchaseController.hasExternalPurchaseController
}
diff --git a/superwall/src/main/java/com/superwall/sdk/dependencies/FactoryProtocols.kt b/superwall/src/main/java/com/superwall/sdk/dependencies/FactoryProtocols.kt
index 2d92acf7..7c7e8e37 100644
--- a/superwall/src/main/java/com/superwall/sdk/dependencies/FactoryProtocols.kt
+++ b/superwall/src/main/java/com/superwall/sdk/dependencies/FactoryProtocols.kt
@@ -3,6 +3,7 @@ package com.superwall.sdk.dependencies
import ComputedPropertyRequest
import android.app.Activity
import com.android.billingclient.api.Purchase
+import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent
import com.superwall.sdk.analytics.trigger_session.TriggerSessionManager
import com.superwall.sdk.billing.GoogleBillingWrapper
import com.superwall.sdk.config.ConfigManager
@@ -119,6 +120,10 @@ interface DeviceHelperFactory {
suspend fun makeSessionDeviceAttributes(): HashMap
}
+interface UserAttributesEventFactory {
+ fun makeUserAttributesEvent(): InternalSuperwallEvent.Attributes
+}
+
interface HasExternalPurchaseControllerFactory {
fun makeHasExternalPurchaseController(): Boolean
}
diff --git a/superwall/src/main/java/com/superwall/sdk/models/paywall/Paywall.kt b/superwall/src/main/java/com/superwall/sdk/models/paywall/Paywall.kt
index 09a75844..d1245f3a 100644
--- a/superwall/src/main/java/com/superwall/sdk/models/paywall/Paywall.kt
+++ b/superwall/src/main/java/com/superwall/sdk/models/paywall/Paywall.kt
@@ -19,6 +19,9 @@ import kotlinx.serialization.Serializable
import java.net.URL
import java.util.*
import android.graphics.Color
+import com.superwall.sdk.logger.LogLevel
+import com.superwall.sdk.logger.LogScope
+import com.superwall.sdk.logger.Logger
@Serializable
data class Paywalls(val paywalls: List): SerializableEntity
@@ -91,7 +94,17 @@ data class Paywall(
) : SerializableEntity {
val backgroundColor: Int by lazy {
- Color.parseColor(this.backgroundColorHex)
+ try {
+ Color.parseColor(this.backgroundColorHex)
+ } catch (e: Throwable) {
+ Logger.debug(
+ logLevel = LogLevel.warn,
+ scope = LogScope.paywallViewController,
+ message = "Invalid paywall background color: ${this.backgroundColorHex}. " +
+ "Defaulting to white."
+ )
+ Color.WHITE
+ }
}
init {
diff --git a/superwall/src/main/java/com/superwall/sdk/paywall/vc/PaywallViewController.kt b/superwall/src/main/java/com/superwall/sdk/paywall/vc/PaywallViewController.kt
index bfb2a3f6..b95f6112 100644
--- a/superwall/src/main/java/com/superwall/sdk/paywall/vc/PaywallViewController.kt
+++ b/superwall/src/main/java/com/superwall/sdk/paywall/vc/PaywallViewController.kt
@@ -21,6 +21,7 @@ import android.view.WindowInsetsController
import android.view.WindowManager
import android.webkit.WebSettings
import android.widget.FrameLayout
+import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.browser.customtabs.CustomTabsIntent
@@ -74,7 +75,6 @@ import com.superwall.sdk.paywall.vc.web_view.messaging.PaywallMessageHandlerDele
import com.superwall.sdk.paywall.vc.web_view.messaging.PaywallWebEvent
import com.superwall.sdk.storage.Storage
import com.superwall.sdk.store.transactions.notifications.NotificationScheduler
-import com.superwall.sdk.view.fatalAssert
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -180,7 +180,6 @@ class PaywallViewController(
private var unsavedOccurrence: TriggerRuleOccurrence? = null
private val cacheKey: String = PaywallCacheLogic.key(paywall.identifier, deviceHelper.locale)
-
//endregion
//region Initialization
@@ -254,7 +253,7 @@ class PaywallViewController(
viewDidAppearCompletion = completion
}
- internal fun viewWillAppear() {
+ fun viewWillAppear() {
if (isSafariVCPresented) {
return
}
@@ -290,7 +289,7 @@ class PaywallViewController(
presentationWillPrepare = false
}
- internal fun viewWillDisappear() {
+ fun viewWillDisappear() {
if (isSafariVCPresented) {
return
}
@@ -298,7 +297,7 @@ class PaywallViewController(
Superwall.instance.dependencyContainer.delegateAdapter.willDismissPaywall(info)
}
- internal suspend fun viewDidDisappear() {
+ suspend fun viewDidDisappear() {
if (isSafariVCPresented) {
return
}
@@ -307,6 +306,12 @@ class PaywallViewController(
trackClose()
}
+ // Reset spinner
+ val isShowingSpinner = loadingState is PaywallLoadingState.LoadingPurchase || loadingState is PaywallLoadingState.ManualLoading
+ if (isShowingSpinner) {
+ this.loadingState = PaywallLoadingState.Ready()
+ }
+
Superwall.instance.dependencyContainer.delegateAdapter.didDismissPaywall(info)
val result = paywallResult ?: PaywallResult.Declined()
@@ -429,7 +434,7 @@ class PaywallViewController(
/// Lets the view controller know that presentation has finished.
// Only called once per presentation.
- internal fun viewDidAppear() {
+ fun viewDidAppear() {
viewDidAppearCompletion?.invoke(true)
viewDidAppearCompletion = null
@@ -818,7 +823,6 @@ class SuperwallPaywallActivity : AppCompatActivity() {
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
)
-
}
}
}
@@ -831,19 +835,25 @@ class SuperwallPaywallActivity : AppCompatActivity() {
return
}
- val view = ViewStorage.retrieveView(key) ?: run {
+ val view = ViewStorage.retrieveView(key) as PaywallViewController ?: run {
finish() // Close the activity if the view associated with the key is not found
return
}
(view.parent as? ViewGroup)?.removeView(view)
-
- if (view is ActivityEncapsulatable) {
- view.encapsulatingActivity = this
- }
+ view.encapsulatingActivity = this
setContentView(view)
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ view.dismiss(
+ result = PaywallResult.Declined(),
+ closeReason = PaywallCloseReason.ManualClose
+ )
+ }
+ })
+
try {
supportActionBar?.hide()
} catch(e: Throwable) {}