Skip to content

Restore Purchase not working after updating to 9.1.1 in Android #2566

@mehul4795

Description

@mehul4795

I have been using the RevenutCat SDK for more than 2 years in my Android app. After upgrading the RevenueCat Android SDK from 8.x.x to 9.1.1, the restore purchase functionality has stoped working in my app and many of the users are complaining regarding the same. After upgrading the SDK version, I haven't made any code changes in the Restore Purchase functionality.

You can find the code that I am using below.

fun restorePurchase(): Flow<PlanPurchaseState> {
        return callbackFlow {
            trySend(PlanPurchaseState.PurchaseInProgress)

            Purchases.sharedInstance.restorePurchasesWith(onError = { error: PurchasesError ->
                trySend(PlanPurchaseState.PurchaseError(error.message))
                close()
            }, onSuccess = { customerInfo ->
                val entitlementInfo =
                    customerInfo.entitlements.all.values.firstOrNull { it.isActive }

                if (entitlementInfo == null) { // No previous purchase found
                    trySend(PlanPurchaseState.PurchaseError(context.getString(R.string.premium_plans_error_no_earlier_purchases)))
                } else {          
                    trySend(PlanPurchaseState.PurchaseSuccess(currentActivePlan))
                }

                close()
            })

            // Waits for the function to get finished and is only called after the close() function is invoked
            awaitClose()
        }
    }

When the above code is executed, I am getting entitlementInfo null every time even though a purchase was made earlier. Any help will be appreciated.

  1. Platform: Android
  2. SDK version: 9.1.1
  3. OS version: Android 16
  4. Android Studio version: Narhwal 2025.1.1 Patch 1
  5. How widespread is the issue. 100% devices affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions