简体   繁体   中英

Native libraries in react-native

is there a way to import / include / require native java android or native objective-c / swift in react native apps?

I mean lets say android's libraries like android volley or android libPhoneNumber?

Only if there is react-native Module wrapper for each of those libraries implemented you can use those from the java script side. See more on how to implement Native Modules at https://facebook.github.io/react-native/docs/native-modules-android.html#content https://facebook.github.io/react-native/docs/native-modules-ios.html#content

Yes, there are two ways:

  1. If the libraries/modules were already wrapped and exposed be React-Native, then just use it (learn how to do it in the link below).

  2. If the libraries/modules were NOT wrapped and exposed, then it has to be wrapped and exposed manually first.

Android's Toast library as an example:

You need to create a bridge. Follow this tutorial about how to use any iOS or Android native library quickly:

React Native: The Quickest Way to Use Any Native iOS or Android Library

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM