diff --git a/RevenueCatUI/Scripts/IPaywallPresenter.cs b/RevenueCatUI/Scripts/IPaywallPresenter.cs
index 14bd8897..4e2c626b 100644
--- a/RevenueCatUI/Scripts/IPaywallPresenter.cs
+++ b/RevenueCatUI/Scripts/IPaywallPresenter.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
-namespace RevenueCat.UI
+namespace RevenueCatUI.Internal
{
///
/// Internal interface for presenting paywalls.
@@ -13,7 +13,7 @@ internal interface IPaywallPresenter
///
/// Paywall presentation options
/// Result of the paywall presentation
- Task PresentPaywallAsync(PaywallOptions options);
+ Task PresentPaywallAsync(RevenueCatUI.PaywallOptions options);
///
/// Presents a paywall only if the user does not have the specified entitlement.
@@ -21,7 +21,7 @@ internal interface IPaywallPresenter
/// Required entitlement identifier
/// Paywall presentation options
/// Result of the paywall presentation
- Task PresentPaywallIfNeededAsync(string requiredEntitlementIdentifier, PaywallOptions options);
+ Task PresentPaywallIfNeededAsync(string requiredEntitlementIdentifier, RevenueCatUI.PaywallOptions options);
///
/// Whether paywall presentation is supported on this platform.
diff --git a/RevenueCatUI/Scripts/PaywallOptions.cs b/RevenueCatUI/Scripts/PaywallOptions.cs
index f1e01519..f4a7d01c 100644
--- a/RevenueCatUI/Scripts/PaywallOptions.cs
+++ b/RevenueCatUI/Scripts/PaywallOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace RevenueCat.UI
+namespace RevenueCatUI
{
///
/// Options for configuring paywall presentation.
diff --git a/RevenueCatUI/Scripts/PaywallPresenter.cs b/RevenueCatUI/Scripts/PaywallPresenter.cs
index 6498a926..41c4b4b7 100644
--- a/RevenueCatUI/Scripts/PaywallPresenter.cs
+++ b/RevenueCatUI/Scripts/PaywallPresenter.cs
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
using UnityEngine;
-namespace RevenueCat.UI
+namespace RevenueCatUI.Internal
{
///
/// Platform-agnostic factory for paywall presenters.
@@ -43,16 +43,16 @@ private static IPaywallPresenter CreatePlatformPresenter()
///
internal class UnsupportedPaywallPresenter : IPaywallPresenter
{
- public Task PresentPaywallAsync(PaywallOptions options)
+ public Task PresentPaywallAsync(RevenueCatUI.PaywallOptions options)
{
Debug.LogWarning("[RevenueCatUI] Paywall presentation is not supported on this platform.");
- return Task.FromResult(PaywallResult.Error);
+ return Task.FromResult(RevenueCatUI.PaywallResult.Error);
}
- public Task PresentPaywallIfNeededAsync(string requiredEntitlementIdentifier, PaywallOptions options)
+ public Task PresentPaywallIfNeededAsync(string requiredEntitlementIdentifier, RevenueCatUI.PaywallOptions options)
{
Debug.LogWarning("[RevenueCatUI] Paywall presentation is not supported on this platform.");
- return Task.FromResult(PaywallResult.Error);
+ return Task.FromResult(RevenueCatUI.PaywallResult.Error);
}
public bool IsSupported()
diff --git a/RevenueCatUI/Scripts/PaywallResult.cs b/RevenueCatUI/Scripts/PaywallResult.cs
index 60505790..dc2e8db5 100644
--- a/RevenueCatUI/Scripts/PaywallResult.cs
+++ b/RevenueCatUI/Scripts/PaywallResult.cs
@@ -1,6 +1,6 @@
using System;
-namespace RevenueCat.UI
+namespace RevenueCatUI
{
///
/// Represents the result of a paywall presentation.
diff --git a/RevenueCatUI/Scripts/PaywallsBehaviour.cs b/RevenueCatUI/Scripts/PaywallsBehaviour.cs
new file mode 100644
index 00000000..f2e1d173
--- /dev/null
+++ b/RevenueCatUI/Scripts/PaywallsBehaviour.cs
@@ -0,0 +1,42 @@
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace RevenueCatUI
+{
+ ///
+ /// MonoBehaviour helper that forwards to the static PaywallsPresenter API so paywalls can be driven from scenes.
+ ///
+ public class PaywallsBehaviour : MonoBehaviour
+ {
+ ///
+ /// Presents a paywall configured in the RevenueCat dashboard.
+ ///
+ /// Options for presenting the paywall.
+ /// A describing the outcome.
+ public async Task PresentPaywall(PaywallOptions options = null)
+ {
+ return await PaywallsPresenter.Present(options);
+ }
+
+ ///
+ /// Presents a paywall only if the user does not have the specified entitlement.
+ ///
+ /// Entitlement identifier to check before presenting.
+ /// Options for presenting the paywall.
+ /// A describing the outcome.
+ public async Task PresentPaywallIfNeeded(string requiredEntitlementIdentifier, PaywallOptions options = null)
+ {
+ return await PaywallsPresenter.PresentIfNeeded(requiredEntitlementIdentifier, options);
+ }
+
+ ///
+ /// Checks if the Paywall UI is available on the current platform.
+ /// Returns true on iOS/Android device builds when paywall is supported; otherwise false.
+ ///
+ /// True if UI is supported on this platform, otherwise false.
+ public bool IsSupported()
+ {
+ return PaywallsPresenter.IsSupported();
+ }
+ }
+}
diff --git a/RevenueCatUI/Scripts/PaywallsBehaviour.cs.meta b/RevenueCatUI/Scripts/PaywallsBehaviour.cs.meta
new file mode 100644
index 00000000..981870c2
--- /dev/null
+++ b/RevenueCatUI/Scripts/PaywallsBehaviour.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 8851586298f4940e5aa3c16b6b1c00de
\ No newline at end of file
diff --git a/RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs b/RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
index 9a594efb..9f866e97 100644
--- a/RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
+++ b/RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
@@ -3,8 +3,9 @@
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Android;
+using RevenueCatUI.Internal;
-namespace RevenueCat.UI.Platforms
+namespace RevenueCatUI.Platforms
{
internal class AndroidPaywallPresenter : IPaywallPresenter
{
diff --git a/RevenueCatUI/Scripts/Platforms/iOS/IOSPaywallPresenter.cs b/RevenueCatUI/Scripts/Platforms/iOS/IOSPaywallPresenter.cs
index b87403a2..287df3f5 100644
--- a/RevenueCatUI/Scripts/Platforms/iOS/IOSPaywallPresenter.cs
+++ b/RevenueCatUI/Scripts/Platforms/iOS/IOSPaywallPresenter.cs
@@ -2,8 +2,9 @@
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using RevenueCatUI.Internal;
-namespace RevenueCat.UI.Platforms
+namespace RevenueCatUI.Platforms
{
internal class IOSPaywallPresenter : IPaywallPresenter
{
diff --git a/RevenueCatUI/Scripts/RevenueCatUI.cs b/RevenueCatUI/Scripts/UI.cs
similarity index 91%
rename from RevenueCatUI/Scripts/RevenueCatUI.cs
rename to RevenueCatUI/Scripts/UI.cs
index da8ae84c..e5fd8424 100644
--- a/RevenueCatUI/Scripts/RevenueCatUI.cs
+++ b/RevenueCatUI/Scripts/UI.cs
@@ -1,14 +1,15 @@
using System;
using System.Threading.Tasks;
using UnityEngine;
+using RevenueCatUI.Internal;
-namespace RevenueCat.UI
+namespace RevenueCatUI
{
///
- /// Main interface for RevenueCat UI components.
+ /// Main interface for RevenueCatUI paywall presentation.
/// Provides static methods to present paywalls.
///
- public static class RevenueCatUI
+ public static class PaywallsPresenter
{
///
@@ -16,7 +17,7 @@ public static class RevenueCatUI
///
/// Options for presenting the paywall
/// A PaywallResult indicating what happened during the paywall presentation
- public static async Task PresentPaywall(PaywallOptions options = null)
+ public static async Task Present(PaywallOptions options = null)
{
try
{
@@ -38,7 +39,7 @@ public static async Task PresentPaywall(PaywallOptions options =
/// Entitlement identifier to check before presenting
/// Options for presenting the paywall
/// A PaywallResult indicating what happened during the paywall presentation
- public static async Task PresentPaywallIfNeeded(
+ public static async Task PresentIfNeeded(
string requiredEntitlementIdentifier,
PaywallOptions options = null)
{
diff --git a/RevenueCatUI/Scripts/RevenueCatUI.cs.meta b/RevenueCatUI/Scripts/UI.cs.meta
similarity index 84%
rename from RevenueCatUI/Scripts/RevenueCatUI.cs.meta
rename to RevenueCatUI/Scripts/UI.cs.meta
index 7a23e805..2315a6c2 100644
--- a/RevenueCatUI/Scripts/RevenueCatUI.cs.meta
+++ b/RevenueCatUI/Scripts/UI.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 2204d27dd3f02469dbaf46f478d096e8
+guid: a364a1333bcd4024936bff2e726ea79a
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/RevenueCatUI/Scripts/revenuecat.purchases-unity-ui.asmdef b/RevenueCatUI/Scripts/revenuecat.purchases-unity-ui.asmdef
index 40602dde..35183459 100644
--- a/RevenueCatUI/Scripts/revenuecat.purchases-unity-ui.asmdef
+++ b/RevenueCatUI/Scripts/revenuecat.purchases-unity-ui.asmdef
@@ -1,6 +1,6 @@
{
"name": "revenuecat.purchases-unity-ui",
- "rootNamespace": "RevenueCat.UI",
+ "rootNamespace": "RevenueCatUI",
"references": [
"revenuecat.purchases-unity"
],
diff --git a/Subtester/Assets/Scripts/PurchasesListener.cs b/Subtester/Assets/Scripts/PurchasesListener.cs
index 32ed4799..dd7b9b95 100644
--- a/Subtester/Assets/Scripts/PurchasesListener.cs
+++ b/Subtester/Assets/Scripts/PurchasesListener.cs
@@ -5,7 +5,6 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
-using RevenueCat.UI;
public class PurchasesListener : Purchases.UpdatedCustomerInfoListener
{
@@ -231,7 +230,7 @@ void PresentPaywallIfNeeded()
private System.Collections.IEnumerator PresentPaywallCoroutine()
{
- var task = RevenueCat.UI.RevenueCatUI.PresentPaywall();
+ var task = RevenueCatUI.PaywallsPresenter.Present();
while (!task.IsCompleted) { yield return null; }
var result = task.Result;
@@ -241,8 +240,8 @@ private System.Collections.IEnumerator PresentPaywallCoroutine()
{
string status = GetPaywallResultStatus(result);
- if (result.Result == RevenueCat.UI.PaywallResultType.Purchased ||
- result.Result == RevenueCat.UI.PaywallResultType.Restored)
+ if (result.Result == RevenueCatUI.PaywallResultType.Purchased ||
+ result.Result == RevenueCatUI.PaywallResultType.Restored)
{
GetComponent().GetCustomerInfo((customerInfo, error) => {
if (error != null)
@@ -264,12 +263,12 @@ private System.Collections.IEnumerator PresentPaywallCoroutine()
private System.Collections.IEnumerator PresentPaywallWithOptionsCoroutine()
{
- var options = new RevenueCat.UI.PaywallOptions
+ var options = new RevenueCatUI.PaywallOptions
{
DisplayCloseButton = false
};
- var task = RevenueCat.UI.RevenueCatUI.PresentPaywall(options);
+ var task = RevenueCatUI.PaywallsPresenter.Present(options);
while (!task.IsCompleted) { yield return null; }
var result = task.Result;
@@ -327,7 +326,7 @@ private System.Collections.IEnumerator PresentPaywallForOfferingCoroutine()
}
// Create options with specific offering
- var options = new RevenueCat.UI.PaywallOptions
+ var options = new RevenueCatUI.PaywallOptions
{
OfferingIdentifier = offeringId,
DisplayCloseButton = true
@@ -335,7 +334,7 @@ private System.Collections.IEnumerator PresentPaywallForOfferingCoroutine()
Debug.Log($"Subtester: Presenting paywall for offering: {options.OfferingIdentifier}");
- var task = RevenueCat.UI.RevenueCatUI.PresentPaywall(options);
+ var task = RevenueCatUI.PaywallsPresenter.Present(options);
while (!task.IsCompleted) { yield return null; }
var result = task.Result;
@@ -393,7 +392,7 @@ private System.Collections.IEnumerator PresentPaywallIfNeededCoroutine()
}
// Create options for the test
- var options = new RevenueCat.UI.PaywallOptions
+ var options = new RevenueCatUI.PaywallOptions
{
OfferingIdentifier = offeringId,
DisplayCloseButton = true // Test with close button enabled
@@ -404,7 +403,7 @@ private System.Collections.IEnumerator PresentPaywallIfNeededCoroutine()
Debug.Log($"Subtester: Testing presentPaywallIfNeeded for entitlement: {testEntitlement}, offering: {options.OfferingIdentifier}");
- var task = RevenueCat.UI.RevenueCatUI.PresentPaywallIfNeeded(testEntitlement, options);
+ var task = RevenueCatUI.PaywallsPresenter.PresentIfNeeded(testEntitlement, options);
while (!task.IsCompleted) { yield return null; }
var result = task.Result;
@@ -414,7 +413,7 @@ private System.Collections.IEnumerator PresentPaywallIfNeededCoroutine()
{
var status = GetPaywallResultStatus(result);
var message = $"PaywallIfNeeded for '{testEntitlement}' result: {status}";
- if (result.Result == RevenueCat.UI.PaywallResultType.NotPresented)
+ if (result.Result == RevenueCatUI.PaywallResultType.NotPresented)
{
message += " (User already has entitlement)";
}
@@ -422,19 +421,19 @@ private System.Collections.IEnumerator PresentPaywallIfNeededCoroutine()
}
}
- private string GetPaywallResultStatus(RevenueCat.UI.PaywallResult result)
+ private string GetPaywallResultStatus(RevenueCatUI.PaywallResult result)
{
switch (result.Result)
{
- case RevenueCat.UI.PaywallResultType.Purchased:
+ case RevenueCatUI.PaywallResultType.Purchased:
return "PURCHASED - User completed a purchase";
- case RevenueCat.UI.PaywallResultType.Restored:
+ case RevenueCatUI.PaywallResultType.Restored:
return "RESTORED - User restored previous purchases";
- case RevenueCat.UI.PaywallResultType.Cancelled:
+ case RevenueCatUI.PaywallResultType.Cancelled:
return "CANCELLED - User dismissed the paywall";
- case RevenueCat.UI.PaywallResultType.Error:
+ case RevenueCatUI.PaywallResultType.Error:
return "ERROR - An error occurred during paywall";
- case RevenueCat.UI.PaywallResultType.NotPresented:
+ case RevenueCatUI.PaywallResultType.NotPresented:
return "NOT PRESENTED - Paywall was not needed";
default:
return $"UNKNOWN - Received: {result}";