3

I have a React Native app, that is using ExpoKit. I can eject if needed.

I want to access the NSUserDefaults object to read a value that has been pushed by AirWatch - a Mobile Device Management system. Basically the app is run in a Managed Environment, and the settings are passed through NSUserDefaults.

I haven't been able to use React Native's Settings (https://facebook.github.io/react-native/docs/settings), as it gives me an error about the internal _settings object being undefined when trying to access this._settings[t].

How to use this Settings module, or what should I do to access this settings object?

Mickaël
  • 3,763
  • 5
  • 26
  • 32
  • Looks like you need to invoke Settings.get(t) to get the value. – Sachin Vas Mar 13 '19 at 06:48
  • @SachinVas invoking `Settings.get("my_key")` is what I was trying to do, and it gives me this error about `_settings` being undefined. Have you been able to use `Settings.get()` successfully? – Mickaël Mar 13 '19 at 16:23

1 Answers1

1

Check your pods, you are most probably missing the subspec "RCTSettings" for pod 'React', it was not added during the eject .. which is really strange.

This is how it looks for me:

  pod 'React',
:path => "../node_modules/react-native",
:inhibit_warnings => true,
:subspecs => [
  "Core",
  "ART",
  "RCTActionSheet",
  "RCTAnimation",
  "RCTCameraRoll",
  "RCTGeolocation",
  "RCTImage",
  "RCTNetwork",
  "RCTText",
  "RCTVibration",
  "RCTWebSocket",
  "RCTSettings",
  "DevSupport",
  "CxxBridge"
]
EmilDo
  • 1,177
  • 3
  • 16
  • 33