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] Error activating Adapty SDK #3001 (wrongParam): Passed parameter "file_location" has invalid type. Expected type: UTF-8 String" #124

Closed efstathiosntonas closed 2 weeks ago

efstathiosntonas commented 1 month ago

Description

I get this error when trying to activate fallbacks. I followed the docs step by step, Android works fine.

[ADAPTY] Error activating Adapty SDK #3001 (wrongParam): Passed parameter "file_location" has invalid type. Expected type: UTF-8 String"

verbose:

 DEBUG  [2024-07-13T09:15:28.801Z] [adapty@2.11.0] "fetch/update_profile": Calling bridge function... {"method": "update_profile", "params": Map {"params" => "{\"birthday\":\"2006-07-12\",\"email\":\"test@tt.com\"}
 DEBUG  [2024-07-13T09:15:29.030Z] [adapty@2.11.0] "parse": Decoding string... {"input": "{\"data\":{},\"type\":\"null\"}"}
 DEBUG  [2024-07-13T09:15:29.030Z] [adapty@2.11.0] "fetch/update_profile": Calling bridge function: OK {"response": "{\"data\":{},\"type\":\"null\"}"}
 DEBUG  [2024-07-13T09:15:29.030Z] [adapty@2.11.0] "updateProfile": Calling method: OK undefined
 DEBUG  [2024-07-13T09:15:29.215Z] [adapty@2.11.0] "setFallbackPaywalls": Calling method... {"paywallsLocationJson": "{\"fileName\":\"ios_fallback.json\"}"}
 DEBUG  [2024-07-13T09:15:29.215Z] [adapty@2.11.0] "fetch/set_fallback_paywalls": Calling bridge function... {"method": "set_fallback_paywalls", "params": Map {"file_location" => "{\"fileName\":\"ios_fallback.json\"}"}}
 DEBUG  [2024-07-13T09:15:29.232Z] [adapty@2.11.0] "fetch/set_fallback_paywalls": Calling bridge function: OK {"error": [Error: {"data":{"error_type":"typeMismatch","name":"file_location","type":"UTF-8 String"},"type":"BridgeError"}]}
 DEBUG  [2024-07-13T09:15:29.234Z] [adapty@2.11.0] "setFallbackPaywalls": Calling method: OK {"error": [Error: #3001 (wrongParam): Passed parameter "file_location" has invalid type. Expected type: UTF-8 String"]}

index.js

async function init() {
  try {
    console.info('[ADAPTY] Activating Adapty SDK...');
    await adapty.activate(Keys.secureFor('ADAPTY_PUBLIC_KEY'), {
      logLevel: 'verbose'
    });

    const paywallsLocation = {
      ios: {
        fileName: 'ios_fallback.json'
      },
      android: {
        relativeAssetPath: 'android_fallback.json'
      }
    };
    await adapty.setFallbackPaywalls(paywallsLocation);
  } catch (error) {
    console.error('[ADAPTY] Error activating Adapty SDK', error.message);
    notify(error, 'error', 'Adapty activation error');
  }
}

init();

what I tried:

  1. run metro with --reset-cache
  2. Cleaned derived data on Xcode
  3. Run on device and simulator (both throw the error)

When you download the fallback json the files do not have an underscore : ios fallback.json. I've downloaded the proper json files for 2.11.X

offtopic:

the github issue template has a typo, in the System info it should be Run npx react-native info and not Run npx react-native

Version

v2.11.0

What platforms are you seeing the problem on?

iOS

System info

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (20) arm64 Apple M1 Ultra
  Memory: 70.78 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.14.0
    path: ~/.nvm/versions/node/v20.14.0/bin/node
  Yarn:
    version: 4.2.2
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.14.0/bin/npm
  Watchman:
    version: 2024.07.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/stathis/.gem/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
efstathiosntonas commented 1 month ago

On Xcode logs I also get:

[Adapty v2.11.0] - WARN: SK1ProductsFetcher: InvalidProductIdentifiers: premium_monthly_package, super_boost_package_5, premium_annual_package

These products are from a dectivated Paywall, why they are still fetched? Why there's no ability to delete the Default paywall on Adapty dashboard? These products do not exist in appstoreconnect nor in Adapty Products.

efstathiosntonas commented 1 month ago

First problem solved, I had to tick the Target Membership on the ios_fallback.json file on the right side panel of Xcode (or when adding the file, check the target at the bottom on the dialog), the documentation is lacking this step.

Screenshot 2024-07-13 at 12 28 50

vladd-g commented 1 month ago

hi @efstathiosntonas, happy to hear that the first problem has been solved!

as for the second one, please feel free to reach out to support@adapty.io