adaptyteam / AdaptySDK-Unity

Unity SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
50 stars 4 forks source link

DecodingFailed #9

Closed shohinsherov closed 1 year ago

shohinsherov commented 1 year ago

Hello. I started the project, but I get an error:

AdaptyListener# <-- SetFallBackPaywalls error Code: DecodingFailed, Message: Failed decoding Adapty.Error, Detail: AdaptyUnityError.DecodingFailed(System.NullReferenceException: Object reference not set to an instance of an object

at AdaptySDK.SimpleJSON.JSONNode.Parse (System.String aJSON) [0x003cb] in D:\MyProjects\Unity\AdaptySDK-Unity-main\Assets\AdaptySDK\JSON\SimpleJSON.cs:517 at AdaptySDK.SimpleJSON.JSONNodeExtensions.ExtractErrorIfPresent (System.String json) [0x00000] in D:\MyProjects\Unity\AdaptySDK-Unity-main\Assets\AdaptySDK\JSON\Error+JSON.cs:47 ) UnityEngine.Debug:Log (object)ё

With what it can be connected?

x401om commented 1 year ago

Hey, @shohinsherov! Could you please specify the plugin version and the platform (iOS or Android) where are you getting this error? Also I am interested, how did you obtain the fallback paywalls data and how do you pass it to the SDK?

shohinsherov commented 1 year ago

Hi, @x401om! Version adapty 2.4.1. I'm getting this error in the Unity editor, Android platform. I'm using this method for caching paywall products


try
        {
            Adapty.GetPaywall(YOUR_PAYWALL_ID, "en", (paywall, error) =>
            {
                if (error != null)
                {
                    Debug.LogError($"Error GetPaywall: \nCode: {error.Code}\nMessage: {error.Message}\nDetail: {error.Detail}");
                    // handle the error
                    return;
                }

                // paywall - the resulting object
                Adapty.GetPaywallProducts(paywall, (products, error) =>
                {
                    if (error != null)
                    {
                        // handle the error
                        Debug.LogError($"Error GetPaywallProducts: \nCode: {error.Code}\nMessage: {error.Message}\nDetail: {error.Detail}");
                        return;
                    }

                    foreach (var product in products)
                    {
                        .....
                    }
                });
            });
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }
x401om commented 1 year ago

@shohinsherov Let me explain the idea of Fallback Paywalls a bit:

Adapty attempts to retrieve a paywall from the server every time the GetPaywall method is called. However, in certain situations, it may not be possible to obtain the most recent data, such as when there is no internet connection or when Adapty Servers are unavailable. To address this issue, the Fallback Paywalls mechanism has been developed. To enable this feature, you must provide a specific JSON object to the SetFallbackPaywalls method immediately after initializing the library. An example of how to use this feature can be found here, and you can refer to our documentation here for more information.

You can download Fallback Paywalls for both platforms in the Adapty Dashboard: Fallback Paywalls Instruction

If you already did everything I described here, please provide full verbose logs, it will help us to understand the issue correctly.

x401om commented 1 year ago

Hey, @shohinsherov how are you doing? Were you able to deal with the issue?

x401om commented 1 year ago

I will close the issue, since there is no response for a long time. Feel free to reopen it in case of any questions.

marvpaul commented 4 months ago

@x401om I got the exact same error which leads me to the question: Can we display the paywalls within the editor at all?