RevenueCat / RevenueCat/react-native-purchases

App needs to be restarted to identify user

Open
#777 28 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug status: needs-additional-info
Dominant language
TypeScript
Stars
1.2k
Forks
117
Avg merge
14h 40m
Merged PRs (30d)
40

Description

Describe the bug
I have lost about 500 paying subscribers because revenuecat is failing to identify my paying users. This started happening after upgrading the library.

For a subscribed user to access their premium features after log in they will need to kill and restart the app.

This is my validateSub function - what am I doing wrong?

export const validateSubscription = () => {
  return (dispatch: Dispatch) => {
    auth().onAuthStateChanged(async (currentUser) => {

      if (!currentUser) {
        return;
      }

      const user = await Purchases.logIn(currentUser.uid);

      const isSubscriptionActive =
        typeof user.customerInfo.entitlements.active.plus !==
        'undefined';

      if (isSubscriptionActive) {
        prettyLog("auth().onAuthStateChanged - You're a PLUS user!");
        return dispatch({ type: SUBSCRIPTION_VALIDATED });
      }
    });

    Purchases.addCustomerInfoUpdateListener(
      async (updatedCustomerInfo) => {
        
        if (
          typeof updatedCustomerInfo.entitlements.active?.plus !==
          'undefined'
        ) {
        
          return dispatch({ type: SUBSCRIPTION_VALIDATED });
        }

        dispatch({ type: SUBSCRIPTION_EXPIRED });
      },
    );
  };
};

I am calling Purchases.configure outside my App.js (very early)

Sometimes the user within the addCustomerInfoUpdateListener will return a non-subbed user while the user inside the onAuthStateChanged IS subscribed. This is really confusing an non-intuitive.

I dont know what else to try and dont want to ship another version and lose whats left.

Please help.

  1. Environment
    1. Platform: iOS and android
    2. SDK version: 6.3.0
    3. OS version:
    4. Xcode/Android Studio version:
    5. React Native version: 0.72.1
    6. SDK installation (CocoaPods + version or manual):
    7. How widespread is the issue. Percentage of devices affected. Almost everyone.
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the reported validateSubscription flow and the Purchases SDK 6.3.0 behavior, then review the linked debugging documentation and reproduce the listener-ordering discrepancy on iOS and Android. Done means identifying why the two callbacks report different subscription states and documenting or implementing a reliable fix with reproduction evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, react-native, typescript
Domain
authentication, mobile, payments
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.