Skip to content

[3.3.0] You need to be activate Adapty once #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
efstathiosntonas opened this issue Feb 3, 2025 · 25 comments
Open

[3.3.0] You need to be activate Adapty once #134

efstathiosntonas opened this issue Feb 3, 2025 · 25 comments
Assignees
Labels
bug Something isn't working

Comments

@efstathiosntonas
Copy link

efstathiosntonas commented Feb 3, 2025

Description

Hi,

after upgrading to "react-native-adapty": "3.3.0" this error started showing up:

Error: #3005 (activateOnceError): You need to be activate Adapty once

and on xcode console:

Adapty activate [Oektfu] encountered an error: 
AdaptyError.activateOnceError([3.3.4]: AdaptyAdapty+Activate.swift#65).
v3.3.4, Adapty/Adapty+Activate.swift#67
  1. There's obviously a typo in the error
  2. Tested in real devices and simulators
  3. The code provided below used to work as a charm with "react-native-adapty": "3.1.0"

on index.js:

async function init() {
  try {
    console.count('activating adapty');
    await adapty.activate(<KEY>), {
      logLevel: 'verbose',
      __debugDeferActivation: __DEV__
    });

    const paywallsLocation = {
      ios: {
        fileName: 'ios_fallback.json'
      },
      android: {
        relativeAssetPath: 'android_fallback.json'
      }
    };
    await adapty.setFallbackPaywalls(paywallsLocation);
  } catch (error) {
    console.error('[ADAPTY] Error activating Adapty SDK', error.message);
    notify(error, 'error', 'Adapty activation error');
  }
}

init();

console.count('activating adapty'); logs only once so IT'S NOT DOUBLE INITed on JS side.

Version

v3.3.0

What platforms are you seeing the problem on?

iOS

System info

System:
  OS: macOS 15.2
  CPU: (20) arm64 Apple M1 Ultra
  Memory: 108.22 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.2
    path: ~/.nvm/versions/node/v20.18.2/bin/node
  Yarn:
    version: 4.6.0
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.1.0
    path: ~/.nvm/versions/node/v20.18.2/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/stathis/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 35.0.0
    System Images:
      - android-25 | Google APIs ARM 64 v8a
      - android-27 | Google APIs ARM 64 v8a
      - android-28 | Google APIs ARM 64 v8a
      - android-29 | Google APIs ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-35 | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.12816248
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/stathis/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.3
    wanted: 15.1.3
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.0
    wanted: 0.77.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
@efstathiosntonas efstathiosntonas added the bug Something isn't working label Feb 3, 2025
@efstathiosntonas efstathiosntonas changed the title [3.1.0] You need to be activate Adapty once [3.3.0] You need to be activate Adapty once Feb 3, 2025
@efstathiosntonas
Copy link
Author

efstathiosntonas commented Feb 3, 2025

I have a hook that fetches a specific paywall:

function useEligibleForTrial() {
  const [eligibleForTrial, setEligibleForTrial] = useState(false);
  const [loadingEligible, setLoadingEligible] = useState(true);

  useEffect(() => {
    console.log('fetching trials');
    async function fetchPaywallAndProducts() {
      try {
        const paywall = await adapty.getPaywall('trials');
        console.log({ paywall });
        if (paywall) {
          const products = await adapty.getPaywallProducts(paywall);
          console.log({ products });
          if (products) {
            setEligibleForTrial(true);
          }
        }
      } catch (e) {
        notify(e, 'error', 'error while fetching subscriptions paywall');
        console.log(e);
      } finally {
        setLoadingEligible(false);
      }
    }

    fetchPaywallAndProducts().catch(console.log);
  }, []);

  return { eligibleForTrial, loadingEligible };
}

This hook is called inside a @lodev09/react-native-true-sheet that lives down the tree, not even close to adapty.activate on index.js (and it's always rendered, it's called with TrueSheet global methods).

Why the hook tries to activate Adapty first before the adapty.activate? This was not an issue with version 3.1.0.

@efstathiosntonas
Copy link
Author

it also happens sometimes in fast-refresh.

@vladd-g
Copy link
Contributor

vladd-g commented Feb 3, 2025

Hi @efstathiosntonas,

Please contact our support team via [email protected], they will assist you further

@pmespresso
Copy link

I'm having the same issue after upgrading, @efstathiosntonas did you find a solution???

@efstathiosntonas
Copy link
Author

@pmespresso no solution since many things have changed in the native part, adapty team is working on it, I’ve contacted support 5-6 days ago.

@mahaaoo
Copy link

mahaaoo commented Feb 13, 2025

I have the same issue and after fast-refresh adapty.getProfile() undefined
But 3.1.0 work well

@detaybey
Copy link

Do I need to downgrade 3.1.0 ? The problem persists.

@vladd-g
Copy link
Contributor

vladd-g commented Feb 17, 2025

Hi @mahaaoo @detaybey

Could you please contact our support team via [email protected]?

@elsa17z
Copy link

elsa17z commented Feb 28, 2025

Same issue, downgraded to 3.1.0 and it went away

@AppleJem
Copy link

AppleJem commented Mar 2, 2025

I have the same issue, and I'm using createPaywallView so I need the 3.3 SDK...

@msvst
Copy link

msvst commented Mar 2, 2025

Same issue

@vladd-g
Copy link
Contributor

vladd-g commented Mar 2, 2025

@AppleJem you can use createPaywallView with 3.1 as well

@vladd-g
Copy link
Contributor

vladd-g commented Mar 2, 2025

@elsa17z @AppleJem @msvst

Could you please contact our support team via [email protected], and send the Adapty logs?

@msvst
Copy link

msvst commented Mar 2, 2025

@vladd-g thanks, already contacted the team via chat

@detaybey
Copy link

detaybey commented Mar 2, 2025

my solution was to check if adapty is already activated using adapty.isActivated()

@efstathiosntonas
Copy link
Author

efstathiosntonas commented Mar 3, 2025

@detaybey this is not a fix but a work around since there seems to be a race condition somewhere , having to call isActivated inside a useEffect hook like the one I provided above with no deps smells bad.

@masulo1212
Copy link

I ran into the same issue in both 3.3.0 and 3.3.1, but when I downgraded to 3.1.0, adapty.activate worked just fine. I'm initializing it outside of RootLayout in _layout.tsx, which should be the correct place, right? I just don't get why the new versions throw an error right from the start.

@efstathiosntonas
Copy link
Author

efstathiosntonas commented Mar 10, 2025

@masulo1212 we're not doing anything wrong, it's definitely a bug on Adapty side, almost 1 month in and no solution yet.

@efstathiosntonas
Copy link
Author

any updates on this one? It's been 2 months!

@efstathiosntonas
Copy link
Author

@vladd-g since it's impossible for all devs in this issue to provide a reproducer, can we connect and share screens?

@visoft
Copy link

visoft commented Apr 24, 2025

Same issue with version 3.4.0

@vladd-g
Copy link
Contributor

vladd-g commented Apr 24, 2025

Hi @visoft, could you please reach out to [email protected]? Thanks in advance!

@tuukkaio
Copy link

tuukkaio commented May 3, 2025

Did you ever find a fix @efstathiosntonas ? Having the same issue with adapty SDK 3.3.0 - 3.4.1

@vladd-g
Copy link
Contributor

vladd-g commented May 3, 2025

Hi @tuukkaio, we’d appreciate it if you could share some details. Could you please reach out to us at [email protected]?

@tuukkaio
Copy link

tuukkaio commented May 3, 2025

I did already @vladd-g . Just waiting to hear back. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests