Skip to content

Fix issue updating customer info on app open#1128

Merged
tonidero merged 3 commits into
mainfrom
fix-issue-updating-customer-info-app-open
Jul 10, 2023
Merged

Fix issue updating customer info on app open#1128
tonidero merged 3 commits into
mainfrom
fix-issue-updating-customer-info-app-open

Conversation

@tonidero

@tonidero tonidero commented Jul 10, 2023

Copy link
Copy Markdown
Contributor

Description

In some situations, we weren't refreshing the customer info on app open. This was caused by #1073. In that PR we changed to fetch current purchases before getting customer info, so we would sync purchases before getting customer info. However, when we fetch customer info during the app open's onAppForeground callback, the billing.purchasesUpdatedListener was not set. Currently, if that listener isn't set, we would just skip the query altogether so we would never get a response.

Thanks @joshdholtz for bringing it up!

@tonidero tonidero added the bug label Jul 10, 2023

dispatch {
ProcessLifecycleOwner.get().lifecycle.addObserver(lifecycleHandler)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. Moved observing the process lifecycle to happen after the billing listeners have been set. I believe it shouldn't cause any issues as far as I could see in the onAppForegrounded callback and my tests didn't reveal any errors either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment if the order of operations is important, feels like this could easily get rolled back by accident in a refactor

}
} else {
// This shouldn't happen, but if it does, we want to propagate an error instead of hanging.
request(PurchasesError(PurchasesErrorCode.UnknownError, "BillingWrapper is not attached to a listener"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this so it's more apparent if this ever happens in the future, but after the other fix, it shouldn't happen.

@tonidero tonidero added pr:fix A bug fix and removed bug labels Jul 10, 2023
@tonidero tonidero marked this pull request as ready for review July 10, 2023 09:46
@tonidero tonidero requested a review from a team July 10, 2023 09:46

dispatch {
ProcessLifecycleOwner.get().lifecycle.addObserver(lifecycleHandler)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment if the order of operations is important, feels like this could easily get rolled back by accident in a refactor

@tonidero tonidero enabled auto-merge (squash) July 10, 2023 12:32
@tonidero tonidero merged commit c360ee9 into main Jul 10, 2023
@tonidero tonidero deleted the fix-issue-updating-customer-info-app-open branch July 10, 2023 12:38

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

tonidero added a commit that referenced this pull request Jul 12, 2023
**This is an automatic release.**

### New Features
* `Trusted Entitlements`: made API stable (#1105) via NachoSoto
(@NachoSoto)

This new feature prevents MitM attacks between the SDK and the
RevenueCat server.
With verification enabled, the SDK ensures that the response created by
the server was not modified by a third-party, and the entitlements
received are exactly what was sent.
This is 100% opt-in. `EntitlementInfos` have a new `VerificationResult`
property, which will indicate the validity of the responses when this
feature is enabled.

```kotlin
fun configureRevenueCat() {
    val configuration = PurchasesConfiguration.Builder(context, apiKey)
        .entitlementVerificationMode(EntitlementVerificationMode.INFORMATIONAL)
        .build()
    Purchases.configure(configuration)
}
```
### Experimental features
* Add await offerings (#1096) via Cesar de la Vega (@vegaro)
### Bugfixes
* Fix issue updating customer info on app open (#1128) via Toni Rico
(@tonidero)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `13773d2` to `b2108fb`
(#1095) via dependabot[bot] (@dependabot[bot])
### Other Changes
* [PurchaseTester] Add option to purchase an arbitrary product id
(#1099) via Mark Villacampa (@MarkVillacampa)
* Fix release path after module refactor (#1129) via Toni Rico
(@tonidero)
* Fix load shedder integration tests (#1125) via Toni Rico (@tonidero)
* Trusted entitlements: New trusted entitlements signature format
(#1117) via Toni Rico (@tonidero)
* Fix integration tests and change to a different project (#1123) via
Toni Rico (@tonidero)
* Move files into src/main/kotlin (#1122) via Cesar de la Vega (@vegaro)
* Remove public module (#1113) via Cesar de la Vega (@vegaro)
* Remove common module (#1106) via Cesar de la Vega (@vegaro)
* Fix flaky integration tests: Wait for coroutines to finish before
continuing (#1120) via Toni Rico (@tonidero)
* Move amazon module into purchases (#1112) via Cesar de la Vega
(@vegaro)
* Trusted entitlements: Add IntermediateSignatureHelper to handle
intermediate signature verification process (#1110) via Toni Rico
(@tonidero)
* Trusted entitlements: Add Signature type to process new signature
response format (#1109) via Toni Rico (@tonidero)
* [EXTERNAL] Add `awaitCustomerInfo` / coroutines tests to
`TrustedEntitlementsInformationalModeIntegrationTest` (#1077) via
@pablo-guardiola (#1107) via Toni Rico (@tonidero)
* Remove feature:google module (#1104) via Cesar de la Vega (@vegaro)
* Remove identity module (#1103) via Cesar de la Vega (@vegaro)
* Remove subscriber attributes module (#1102) via Cesar de la Vega
(@vegaro)
* Delete utils module (#1098) via Cesar de la Vega (@vegaro)
* Remove strings module (#1097) via Cesar de la Vega (@vegaro)
* Update CHANGELOG.md to include external contribution (#1100) via Cesar
de la Vega (@vegaro)
* [EXTERNAL] Add missing `fetchPolicy` parameter to `awaitCustomerInfo`
API (#1086) via @pablo-guardiola (#1090) via Toni Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants