Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How to access the iOS user defaults in React Native?

$
0
0

I'm trying to access my iOS UserDefaults in my React Native app. I tried this with Settings from react-native.

I set the user defaults like this (native in Swift)

userDefaults?.set("test", forKey: "test")

and also tried it like this

UserDefaults.standard.set("test", forKey: "test")

And I'm trying to log it like this in my react-native app

import {Settings} from 'react-native';

const test = Settings.get('test'); 
console.log(test);

This logs undefined

I can't find a proper example anywhere, so I hope someone can help me out here.
I need to use the watchKeys() method for the purpose of my app, so react-native-user-defaults is not a solution in my case.

Thanks in advance!


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>