Solved

Purchases not restoring automatically on Android when calling configure with another app user id

  • 7 December 2023
  • 2 replies
  • 67 views

Badge +3

I am working on preparing an Android app to properly support the `Transfer to new App User ID` behavior. Up until now, the project on RevenueCat was blocking transfers.

 

The app offers access to content based on a subscription, and the users require an account to purchase any subscription.

 

While reading the documentation, I noticed this section that mentions the following auto-transfer behavior:

So I made the following changes - as instructed by the docs here - , to make sure the existing subscription tied to the Google Play account doesn’t transfer to an anonymous user id:

  • Only call `configure` or `login` on the SDK when the user is logged in the app (has a user id)
  • Never call `logout` on the SDK

However, the problem that I noticed is that when I log in to another in-app account, the auto transfer behavior that is mentioned on the doc snippet shown at the beginning is not happening. Is that section of the documentation outdated or am I missing something?

Here is an example scenario that I ran in sandbox mode:

  1. Create an in-app account (account1@example.com) and subscribe
  2. Log out
  3. Create another in-app account and log in (account2@example.com)

Expected result (based on the docs): The existing subscription should be automatically transferred to account2@example.com

Actual result: No TRANSFER webhook is present when I monitor the latest webhooks sent in RevenueCat dashboard, thus the subscription is not transferred automatically. Also, I tried force stopping and restarting the app, but the subscription did not transfer in this case either.

However, if I call `Purchases.sharedInstance.restorePurchasesWith` when account2@example.com is logged in, the subscription is transferred properly to the new account.

 

I don’t mind this, I actually think it’s better this way, but I still don’t understand why that behavior mentioned in the docs is not happening in my tests. What I want to get is a clarification, because I don’t want to release the app like this and then be caught off guard when in Prod, that behavior starts happening to users. 

 

Thank you!

icon

Best answer by Ryan Glanz 12 December 2023, 23:30

View original

2 replies

Badge +3

Extra clarification: I am on Android SDK v6.9.5 - I am not on the latest version because of this issue

Not sure if this matters but I thought I’d mention it.

Userlevel 3
Badge +8

Hi Radu,

It looks like we shipped a change recently to not transfer the purchase immediately on configure. So I will go update those docs.

If you did want them to transfer right away, you could use syncPurchases, which is the programmatic-safe version of restorePurchases.

Reply