AdaptySDK-React-Native: Error: #3005 (activateOnceError): You need to be activate Adapty once
Hello,
We just upgraded to version 2.2.1
. We migrated to every function and new stuff.
import { adapty } from "react-native-adapty";
useEffect(() => {
(async () => {
await adapty.activate(ADAPTY_SDK_PUBLIC_KEY);
})();
}, []);
Here is my activation code on App.tsx
.
Each time it gives me the Error: #3005 (activateOnceError): You need to be activate Adapty once
and we do not call adapty.activate
else where for sure.
Even sometimes it gives #2002 (notActivated): The Adapty is not activated
but probably it is because of the development environment and stuff.
What should I do to fix this warning? It was all working great on the 1.3.13
version. I’m thinking to downgrade the version.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 35
Commits related to this issue
- feat: native memoization for activation activateOnceError #42 — committed to adaptyteam/AdaptySDK-React-Native by divanc a year ago
If you wonder: The memoization was a nice pattern to use, but it turned out to be inconsistent in my realization. I’ve made argument memoization on JS side, which totally worked on my end. Hot reload haven’t dropped the variables values, BUT for some bundler occasionally decided to drop JS variables and perform full reload cycle. So on a native side Adapty was active, whereas on JS side it was considered never called. In v2.3.6 I’ve moved memoization to native layers, duplicating the code. But hey, this is the only solution, where RN bundler would certainly not interfere
v2.3.6 MUST solve your issue! I’m going to write some more here today
Sorry, had to jump on another task. Diving in…
@WrathChaos please, check out v2.3.0!
With this release I was able to solve both of your errors on my end. To prevent paywall fetching before activation mutex, I moved it outside of component as you can see in example App.tsx.
You can call this activation in any JS file, just make sure to import it to your core.
Hey! I do not see any way to get
notActivated
afteractivateOnceError
. I’m going to need a reproducible snippet for that, if you are able to make one.About
activateOnceError
. This is not an incorrect behavior as is. You activate adapty once you cold boot your application. Hot reload/Fast Refresh technology re-executes useEffect and most other hooks on every refresh, whereas activation status persists.Now, I’m to blame for not giving enough thought about this being a problem. I persisted only one call with
useRef<boolean>
or just wrappedactivate()
into atry {} catch {}
block to ignore the error.I’ll try to make something smart for the following release, that would not incorporate any complex logic. In the meantime, can you try any of my proposed solutions?