-
Notifications
You must be signed in to change notification settings - Fork 20
Paywalls #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paywalls #649
Conversation
tonidero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the approach makes sense... I just have that question about how the presentPaywallIfNeeded method would look like and whether that could cause any UI glitches by presenting the proxy activity without need though.
Co-authored-by: Cesar de la Vega <[email protected]>
…es-unity into feat/add-revenuecatui
|
This PR requires RevenueCat/purchases-android#2695 |
tonidero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good! Just some minor questions and comments
...enueCatUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/PaywallUnityOptions.java
Show resolved
Hide resolved
...tUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/PaywallTrampolineActivity.java
Show resolved
Hide resolved
...tUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/PaywallTrampolineActivity.java
Outdated
Show resolved
Hide resolved
RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
Outdated
Show resolved
Hide resolved
RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
Outdated
Show resolved
Hide resolved
RevenueCatUI/Scripts/Platforms/Android/AndroidPaywallPresenter.cs
Outdated
Show resolved
Hide resolved
…ity and correct usage of launch
tonidero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All makes sense to me. Amazing job on this! Only question is whether we want to get the improvements in #682 before shipping this, since it could be a breaking change later otherwise.
# Conflicts: # Subtester/Assets/Plugins/Android/mainTemplate.gradle # Subtester/ProjectSettings/AndroidResolverDependencies.xml
This wasn't intended to be merged with #649
Required for RevenueCat/purchases-unity#649 (cherry picked from commit 656542a)
We created a
PaywallProxyActivity, instead of using the regular fragment we normally use for presenting paywalls in the hybrids. The reason is that we can't use Unity apps use UnityPlayerActivity as the main activity, which is not FragmentActivity. In Flutter we ask devs to implement FragmentActivity in their Activity, but it's not easy to do that in Unity.For callbacks we use UnitySendMessage, since that's the simplest way without having to rewrite the way we present paywalls to be able to communicate paywall results. It Unity's built-in GameObject messaging system, which I tested and acts as a queue, which is nice since it means the message will come back as soon as
PaywallProxyActivityis closed, behaving very similar toonActivityResult. This avoids rewriting existing paywall presentation architecture, which was in progress and we can still do if we want to support real-time paywall notifications.To hold the Java code, I created a
androidlibfolder, following the docs https://docs.unity3d.com/Manual/android-library-plugin-create.html. The reason is that it's the only way to include an AndroidManifest.xml, the alternative is building an aar, which wuld require external build process and complicate development workflow.EDIT: The circular dependency issue is not an issue anymore and has been solved with #649 (comment), but keeping it here for reference
Circular dependency issue
This is how the Gradle dependencies look like:
We need to call Unity functions (see
UnityBridge) using reflection. The androidlib is converted into a module, and theunityLibrarymodule depends on it (implementation project(':RevenueCatUI.androidlib'). That means adding a dependency onunityLibraryinRevenueCatUI.androidlibwould create a circular dependency. That's why I build theUnityBridge.Usage
Followups