adaptyteam / AdaptySDK-React-Native

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

Code not executed after call the adapty.makePurchase method #116

Closed KristianLentino99 closed 6 months ago

KristianLentino99 commented 6 months ago

Description

Hi! first of all, congrats, your SDK is very easy to use and also your docs are quite good! I have some really strange problems (both on IOS simulator and on a closed alpha on a real Android device). I've been following your tutorials and I have a method that is executed in an useEffect(() => ,[]) to fetch the paywall and the products, below an example:

try {
      const id = 'placement-id'
      const locale = 'en'

      const paywall = await adapty.getPaywall(id, locale)
      const products = await adapty.getPaywallProducts(paywall)
      setProducts(products)
    } catch (error) {
      console.error(error)
    }

this works fine and I'm able to retrieve my products. Then when I try to press the purchase button I have a method like this:

const handleOnSubmitCart = async () => {
    console.log(products[0])
    try {
      const response = await adapty.makePurchase(products[0])
      alert(response.customerUserId)
    } catch (error) {
      console.error(error)
    }
  }

and here I have really strange behavior. After the bottom sheet of IOS/Google closes, it seems I can't get any info, both on the catch or on the line after the makePurchase method. I've also deployed a closed test on my google developer account but after paying the alert is never shown. Something that could be interesting is that after the bottom sheet closes, after more or less 1 second it gets reopen, even if I don't have any makePurchase on some hook to show it on mount of components, the only place where I have the makePurchase is the method which I use on the onPress event of the purchase button, like this:

<Button
  onPress={handleOnSubmitCart}
/>

One additional info that can be useful is that I'm running on expo 49 and I have this trick to make Adapty work at the moment:

"plugins": [
            "expo-router", [
                "expo-build-properties",
                {
                    "android": {
                        "extraMavenRepos": [
                            "../../node_modules/react-native-adapty/lib/android/localMaven"
                        ]
                    }
                }
            ]
        ],

Version

2.10.0

What platforms are you seeing the problem on?

iOS, Android

System info

System:
  OS: macOS 14.2.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 87.06 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  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.72.10
    wanted: 0.72.10
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
vladd-g commented 6 months ago

hi @KristianLentino99, thank you!

Do you see anything in the logs after the bottom sheet closes? Both native layer logs and js layer logs. Do you see anything if you close the bottom sheet without making a purchase?

Something that could be interesting is that after the bottom sheet closes, after more or less 1 second it gets reopen

Does it happen on iOS on a simulator? Or somewhere else? As it's ok for a simulator

KristianLentino99 commented 6 months ago

Hi @vladd-g , after the bottom sheet gets closed after paying in sandbox environmente both on IOS simulator and a real android device it seems I dont have any information returned. If you look at my snippet for the purchase I have an alert after the makePurchase method, but this alert is never shown. Tha android app is a closed test inside google debeloper console so I suppose that on this scenario the alert should be shown, while I can imagine that on simulators things are different. Anyway the logs appear only if I close the bottom sheet without paying, if pay no log is shown, even if I set the adapty SDK to verbose.

KristianLentino99 commented 6 months ago

@vladd-g and yeah, the bottom sheets gets reopened only on the simulator. Good to know that it's the correct behavior

KristianLentino99 commented 6 months ago

@vladd-g another info that could be useful is that I'm trying to buy a consumable item (coins)

vladd-g commented 6 months ago

Good to know that it's the correct behavior

I wouldn't say correct, it's just the expected behavior on a simulator, but I'd test purchases on a real device in case of iOS (on Android an emulator is also acceptable in case it has Google Play)

vladd-g commented 6 months ago

@KristianLentino99

if pay no log is shown, even if I set the adapty SDK to verbose.

Do you mean no logs at all on both native and JS sides, even those are not directly related to Adapty yet can tell the reason?

KristianLentino99 commented 6 months ago

@vladd-g on my expo server I didn't see any logs on the IOS simulator. I'll retry ti do the same tomorrow on an android dev build

KristianLentino99 commented 6 months ago

Hi @vladd-g , I've tested on a real Android device and I found out that I was having problems with the Service account key file. After setting it correctly it works. I'll try to test the IOS purchase on a real device, I think that my issue can be closed, sorry for disturbing you!

vladd-g commented 6 months ago

hi @KristianLentino99, happy to hear that the problem is gone!

ouchou commented 5 months ago

Hello I have the same issue right now on IOS I don't know if the developer who opened this has fixed the error somehow on IOS if yes could please provide the solution. I already tested this on a real device and issue still persists. Thanks in advance.

efstathiosntonas commented 5 months ago

Same here, on simulator the payment sheet opens up again immediately after I enter the sandbox password. Funny thing is, 3 days ago it was working fine, it just started doing this. My gut says that there is an unfinished transaction driving the SK crazy.

I've sent an email on adapty support, still waiting for a response after 1 day.