adaptyteam / AdaptySDK-Flutter

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

abTestName key not found #81

Closed ahmdt closed 1 year ago

ahmdt commented 1 year ago

With 2.3.1 i get this error. It seems that _Keys.abTestName is null for my paywall (free user):

[AdaptyFlutter v2.3.1] - VERBOSE: --> Adapty.identify()
[AdaptyFlutter v2.3.1] - VERBOSE: --> Adapty.get_paywall()
[AdaptyFlutter v2.3.1] - VERBOSE: <-- Adapty.identify()
[AdaptyFlutter v2.3.1] - VERBOSE: <-- Adapty.get_paywall()
┌──────────────────────────────────────────────────────────────────────────
│ type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ #0   MapExtension.object (package:adapty_flutter/src/models/private/json_builder.dart:45:56)
│ #1   AdaptyPaywallJSONBuilder.fromJsonValue (package:adapty_flutter/src/models/private/adapty_paywall_json_builder.dart:27:29)
│ #2   Adapty.getPaywall (package:adapty_flutter/src/adapty.dart:101:37)
│ #3   <asynchronous suspension>
│ #4   PaywallMiddleware._showPaywall (package:sleeptales_app/usecase/paywall/paywall_middleware.dart:22:29)
│ #5   <asynchronous suspension>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Manual BugSnag Notification
└───────────────────────────────────────────────────────────────────────────
x401om commented 1 year ago

Hey, @tonbert! Could you specify on which platform the error occurred, iOS or Android?

ahmdt commented 1 year ago

It was iOs on iPhone 14 Pro and the local simulator as well. I added an empty default string to abTestName and it worked again. It seems like this data should be nullable

x401om commented 1 year ago

@tonbert could you please clarify, what do you mean by "I added an empty default string to abTestName"?

When you create an ab-test, this field is required (see screenshot).

CleanShot 2023-02-27 at 14 58 21@2x

I also do not fully understand why you think that the problem was exactly in the abTestName parameter, while the stackTrace error points to another location. May I ask you to describe your steps in a little more detail, as well as attach the verbose log from the Flutter SDK and iOS SDK?

ahmdt commented 1 year ago

The class declaration in the adapty_paywall.dart file states that the abTestName field is not nullable. However, since I am Free free user I cannot create AB tests. The json data from Adapty when querying the paywall sends no or a null abTestName field. That's why it crashes on deserialization.

Update: I added an empty string so that the deserialization works and I can continue working. Whether this works as a permanent workaround I don't know.

x401om commented 1 year ago

The point is that the ab_test_name field is actually required and should always be present, even if the paywall is not an AB-test. So I don't think your plan is the problem.

I suppose our next steps should be this:

1) Send me as a email your Company name and a email address, to which the account is registered; 2) Add the full verbose log that comes from Adapty-Flutter and Adapty-iOS so that we can see all the errors that occur during the process; 3) "I added an empty string so that the deserialization works" – please attach a code snippet, where exactly did you add this?

ahmdt commented 1 year ago

Ok I don't get it. All of a sudden there comes a value with and I can receive the paywall...problem solved. Thanks for the time