Question

Unwanted behavior on Android when allowing purchase transfer

  • 19 September 2022
  • 1 reply
  • 23 views

Badge

Platform: Android
Store: Google Play
Product Type: Monthly Subscription
RevenueCat Purchases Version: com.revenuecat.purchases:purchases:5.1.0

 

Hi,

I am facing a situation that I'm not sure how to properly handle, related to restore behavior.

 

Up until now, our project had the "Restore behavior" option to "Block restores". 

Now, we want to start allowing users to restore their subscriptions.

 

The problem is that the Android app has unwanted behavior if we turn that "Restore behavior" option to "Transfer purchases" - to quote the documentation

 

"Due to platform limitations, purchases will be transferred as soon as you call `configure` if a user's purchases are already associated with another app user ID.

This may cause unexpected transfers of purchases between app user IDs, especially for apps with optional logins or users with multiple devices. To prevent this behavior, you should wait to call `configure` until you have the appropriate app user ID for your customer."

 

The app has optional login - meaning you can use a limited subset of features without an account.

This means that if I call `configure` - like I do currently on app startup, if the user is not logged in at that point, then any already existing purchase (associated with the Google Play account) is attempted to be transferred from the old app account which has a proper user id to an anonymous user id - via the `TRANSFER` webhook event.

The documentation says "you should wait to call `configure` until you have the appropriate app user ID for your customer"

--- but I need RevenueCat to be initialized before that point, so I can get data related to the subscription offer, which is advertised in the UI before the user is signed in. Example: "Try now for 7 days".

 

Accessing the Purchases instance to get that data without calling `configure` beforehand would result in the following exception: There is no singleton instance. Make sure you configure Purchases before trying to get the default instance.

 

I'm a bit stuck here and I'm not sure what to do. We could, of course, ignore the `TRANSFER` webhook on our backend if the `transferred_to` array doesn't contain a proper user id that is stored in our database, but is that something that is safe to do on our side? Won't RevenueCat get out of sync with our server in that case?

 

I highly appreciate any input here.

Thank you!

Radu
 


1 reply

Badge +1

I have the same exact issue with having the optional login. The only thing that seems to solve it is calling configure immediately after the user signs in instead of when the app loads, otherwise the transfer is made to the anonymous user.

Reply