in app messages support#1290
Conversation
| * If this setting is disabled, you can show the toast by calling | ||
| * [Purchases.showDeclinedPaymentMessageIfNeeded] | ||
| */ | ||
| fun showDeclinedPaymentMessagesAutomatically(showDeclinedPaymentMessagesAutomatically: Boolean) = apply { |
There was a problem hiding this comment.
not married to the naming
There was a problem hiding this comment.
I've been thinking about it... From the documentation, this seems to be the only use case for inapp messages right now, but the naming in Google Play seems more generic, so I wonder if we should keep it generic as well and have it be showInAppMesssagesAutomatically... Will keep it like this for now since it's clearer what's going to be doing for now, but we might need to rename it in the future if Google adds more functionality.
|
|
||
| override fun isConnected(): Boolean = billingClient?.isReady ?: false | ||
|
|
||
| override fun showInAppMessagesIfNeeded(activity: Activity) { |
There was a problem hiding this comment.
getting the activity might actually be tricky here
There was a problem hiding this comment.
Was able to get it by using an ActivityLifecycleCallback in PurchasesOrchestrator
…lient inapp messages + other fixes
|
|
||
| override fun isConnected(): Boolean = billingClient?.isReady ?: false | ||
|
|
||
| override fun showInAppMessagesIfNeeded(activity: Activity) { |
There was a problem hiding this comment.
Was able to get it by using an ActivityLifecycleCallback in PurchasesOrchestrator
| import android.os.Bundle | ||
|
|
||
| @Suppress("EmptyFunctionBlock") | ||
| internal interface CustomActivityLifecycleHandler : ActivityLifecycleCallbacks { |
There was a problem hiding this comment.
This interface just adds default empty implementations to all callbacks so we can just use the ones we need in PurchasesOrchestrator
| val inAppMessageParams = InAppMessageParams.newBuilder() | ||
| .addInAppMessageCategoryToShow(InAppMessageParams.InAppMessageCategoryId.TRANSACTIONAL) | ||
| .build() | ||
| val weakActivity = WeakReference(activity) |
There was a problem hiding this comment.
I'm using a weak reference here since I want to avoid any chance of leaking the activity if there is a problem connecting to the billing client.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1290 +/- ##
==========================================
- Coverage 85.94% 85.82% -0.12%
==========================================
Files 184 185 +1
Lines 6274 6314 +40
Branches 911 916 +5
==========================================
+ Hits 5392 5419 +27
- Misses 536 546 +10
- Partials 346 349 +3
☔ View full report in Codecov by Sentry. |
### Description Followup to #1290. This improves the API to future-proof them in case Google adds new in-app message types in the future. This is not a breaking change since the previous APIs haven't been released yet.
### Breaking Changes * Support for Billing Client 6 (#1209) via Mark Villacampa (@MarkVillacampa) * Bump minimum sdk version to Android 4.4 (API level 19) (#1265) via Mark Villacampa (@MarkVillacampa) * in app messages support (#1290) via Andy Boedo (@aboedo) ### Bugfixes * Add `awaitRestore` to customEntitlementComputation library (#1275) via Toni Rico (@tonidero) ### Other Changes * Future-proof in-app message APIs in case new types are added (#1293) via Toni Rico (@tonidero) * `Code style`: enabled `ALLOW_TRAILING_COMMA` (#1280) via NachoSoto (@NachoSoto)
This PR provides support for in app messages for declined payments with BillingClient. They can be shown using
Purchases.showDeclinedPaymentMessageIfNeeded. It also provides an API inPurchasesConfigurationto display those messages automatically.