lyubo / react-native-sodium

ISC License
61 stars 46 forks source link

Sodium is null #26

Closed YMIUA closed 4 years ago

YMIUA commented 5 years ago

I try using Sodium in my project, but I have a problem with import Sodium. After import Sodium from 'react-native-sodium', object Sodium is null. I use your example to encrypt, but I have the same error. P.S before linking Sodium object has been undefined.

neutrous commented 4 years ago

You have to manually register this package. Basically, go to android/*/MainApplication.java to do this:

...
import org.libsodium.rn.RCTSodiumPackage;
...

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          ...,
          new RCTSodiumPackage(),
...
simonas-notcat commented 4 years ago

For iOS you need to:

react-native link react-native-sodium
cd ios/
pod install
lyubo commented 4 years ago

I'll close this one as there is no feedback from the reporter.