Search code examples
react-nativein-app-purchase

Adapty React Native: "Failed to deserialize a native error message" on SDK initialization


(while the question is similar to Error when integrating Adapty sdk React Native Expo for in app purchase I have more details that might help on resolution)

I'm trying to initialize the SDK:

   adapty.activate(env.adaptySdkKey, { customerUserId }).then(async () => {
          ...
   });

My env.adaptySdkKey and customerUserId are set and valid. However when I'm initing I get a console warning:

Failed to deserialize a native error message

Digging down further into React Native bridge and putting a breakpoint there reveals the following details with the provided error data object:

{
  "code":"adapty_native_error",
  "message":"Argument 'id' was not passed to a native module.",
  "domain":"RCTErrorDomain",
  [...]
}

I'm on Adapty React Native SDK 2.4.2.

What am I doing wrong? (Tried iOS-only. I currently can't test Android so I don't know it happens on Android too or not)


Solution

  • I'm the developer of this library :) By all means, you can open issues, when you experience something like this and I'll try to help.

    From the provided code I can see only one possible buggy place: customerUserId should be a nullable string (string | undefined | null) and native layer may throw an error if you've passed a number for example.

    Although in this customerUserId case the error should be: "Argument 'user_id' was not passed to a native module." The only place, where I can expect 'id' is in adapty.getPaywall(paywallId) method.

    Make sure, that:

    1. getPaywall is not being called somewhere without a first required argument
    2. The first paywallId argument is of string type

    I might not receive updates here, so feel free to open an issue if a problem remains. Meanwhile, I'll make sure that errors deserialize without any pain