adaptyteam / AdaptySDK-React-Native

React Native SDK for growing in-app subscriptions
https://docs.adapty.io/docs/quickstart
MIT License
122 stars 12 forks source link

`adapty.activate()` function crashes the app when API key is invalid #109

Closed jamcry closed 4 months ago

jamcry commented 6 months ago

Description

When an invalid API_KEY is provided to adapty.activate(API_KEY) function, it doesn't throw an error and the whole app crashes. When the correct api key is provided, it works without any issues. (Please check the video)

Expected Behaviour: .activate function throws an error, and it's caught by my code in the app Actual Behaviour: No error is thrown, instead whole app crashes. Possibly due to unhandled exception in the sdk Why it's critical?: For any reason, app might not get the correct credentials for adapty, which would cause whole app to crash and make it unusable

https://github.com/adaptyteam/AdaptySDK-React-Native/assets/22727931/760ff2bd-8b8f-4e9f-aaca-c02eaeb80452

This hook is in the main entry point of the application, App.ts:

  useEffect(() => {
   function setUpAdapty() {
      adapty
        .activate("IncorrectKey", {
          customerUserId: "TestUser",
          logLevel: "error",
        })
        .then(() => {
          Alert.alert("✅ Adapty activated");
        })
        .catch((e) => {
          Alert.alert("❌ Adapty activation failed");
          console.log({
            e,
          });
        });
    }

    setUpAdapty();
  }, []);

Version

v2.9.1

What platforms are you seeing the problem on?

iOS

System info

System:
  OS: macOS 14.3
  CPU: (8) arm64 Apple M1 Pro
  Memory: 129.89 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.0
    path: ~/.nvm/versions/node/v18.17.0/bin/node
  Yarn: Not Found
  npm:
    version: 9.6.7
    path: ~/.nvm/versions/node/v18.17.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.4
    wanted: 0.73.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: true
  newArchEnabled: false

----
Expo Details--
expo version: 50.0.6
eas-cli version: 7.1.3 (darwin-arm64 node-v18.17.0)
vladd-g commented 6 months ago

hi @jamcry, thank you!

It's not actually a crash, but a debug-only assertion at the native iOS level