I’m trying to create an npm package for React Native.
This package would exist as a module to the already existing React Native SDK (core module).
Something like #react-native-firebase/app <—> #react-native-firebase/crashlytics relation.
I understand that I should start with create-react-native-library
and to add the core module as a peerDependencie.
The before-mentioned React Native SDK has a bridge to native SDKs for iOS and Android. Those native SDKs have additional modules that I want to include in my npm package.
And this is where I get lost, how to include those native modules in my package. Any advice is more than appreciated.
This question is in the neighborhood of what I’m asking but it doesn’t provide the explanation that I need.
iOS
Do I need to add something like this in .podspec file:
s.dependency 'iOS_MODULE_THAT_I_WANT', '1.0.0'
Are there other steps to take? If so, what would be equvelent od that for Android.
Related
I'm trying to connect with a running PocketBase database. Normally, I would use their Javascript SDK to achieve this, but the package does not get shipped to the mobile device during the build process.
This means I either have to build my own set of functions to mimic the working of the PocketBase Javascript SDK, or use a NativeScript plugin.
I could not find an existing plugin mentioning PocketBase, does anyone know of a plugin that facilitates this?
I tried to install the PocketBase Javascript SDK directly from NPM using npm install pocketbase, but this module does not check shipped to the mobile device during the build process.
For example:
import PocketBase from 'pocketbase'
console.dir(PocketBase)
Running this from a NativeScript app logs "null" to the console.
Using import * as PocketBase from 'pocketbase' ended up working for me.
I installed the pocketbase SDK with npm i --save pocketbase.
For whatever reason using import PocketBase from 'pocketbase' as the PocketBase documentation suggests doesn't work in this case.
My company is doing Mobile Device Management with Microsoft Intune. We've successfully deployed an internal iOS app (using the Apple Developer Enterprise Program).
With Intunes' configuration settings we're trying to make each user's individual email available to the mobile app.
https://learn.microsoft.com/en-us/mem/intune/apps/app-configuration-policies-use-ios
How do you normally access these types of settings in an app? I found this library but I'd need to eject from Expo which is not ideal for me:
https://github.com/robinpowered/react-native-mdm
You can add expo support into react-native-mdm by fork react-native-mdm and use Config Plugins
here is the PR for adding expo support into the native package https://github.com/Shobbak/react-native-compressor/pull/62
After adding support you just have to do
Managed Expo
yarn install react-native-mdm_from_your_fork
Add the react-native-mdm plugin to your Expo config (app.json, app.config.json or app.config.js):
{
"name": "my app",
"plugins": ["react-native-mdm"]
}
Finally, compile the mods:
expo prebuild
To apply the changes, build a new binary with EAS:
eas build
As the MDM has native dependencies, You'll not be able to make it with Expo. Expo projects are written only in JavaScript and don't support packages that contain Objective-C or Java (Native code/dependencies).
Expo provides an advanced SDK called ExpoKit for when you absolutely need to use custom native code. However, there are some cases where developers need native capabilities outside of what Expo offers directly. The most common situation is when a project requires a specific Native Module (like MDM) that is not supported by React Native Core or the Expo SDK. You'll have to detach the Expo project to create Xcode and Android Studio projects that contain ExpoKit. This step will generate android and ios project directories. Then you would add custom Objective-C or Java the same way as with any other Xcode or Android Studio project.
The Expo docs warn about some of the downsides of writing custom native code and discourage most of our developers from taking this route, as Expo's motive, almost everything you need to do is better accomplished in a cross-platform way with JS. Writing in JS enables you to best take advantage of code aster deployment and benefit from ongoing updates and support from Expo. You should only do this if you have a particular demand from native code which Expo won’t do a good job supporting, such as (for example) specialized CPU-intensive video processing that must happen locally on the device, Custom native libraries.
Here are only two options to support the MDM, either eject the project or create react-native-cli project and migrate your project into newly created one.
I am currently working on a react application to complement a web application, and have been tasked with implementing an self-sovereign identity solution using the Kilt.io protocol. This worked fine for the web app, however I am running some issues when it comes to the react native app. I initially wanted to use Expo, however the #kiltprotocol/sdk-js package depends on #polkadot packages to function, which in turn depends on the NodeJS crypto package. However, as it is a NodeJS package, the module cannot be found when trying to run my expo app. It seems like it is possible to load the crypto module using the rn-nodeify package when not using expo (although I have not actually tested this myself for this use case yet), however I was wondering if anyone knows of a solution that would work for an expo project.
Try
expo install expo-crypto
then create a "metro.config.js"
put in
module.exports = {
resolver: {
extraNodeModules: {
crypto: require.resolve('expo-crypto'),
}
}
};
I am setting up a new expo application and want a support in my application.
I want to know how to add the android sdk of agora.io into my expo project?
Unfortunately both the iOS and Android SDKs for agora.io require editing of native code. As Expo abstracts native code away from you meaning the only way to access native code is to either create your project using react-native init or by ejecting your Expo project.
Looking at the docs for iOS you can see that it requires you to add the SDK either by using cocoa pods or by inserting it directly into you Xcode project file. https://docs.agora.io/en/Voice/ios_audio?platform=iOS#add-the-agora-sdk-to-your-project
Similarly for Android you have to add the SDK inside the Android folder and make changes to the build.gradle files.
https://docs.agora.io/en/Voice/android_audio?platform=Android#add-the-agora-sdk-to-your-project
However you are in luck. There are a couple of wrappers around the SDKs that can be used with a full react-native project or an ejected Expo project.
https://github.com/AgoraIO/React-Native-SDK
https://github.com/syanbo/react-native-agora
The above answer is out of date now, Agora does offer expo support per the following documentation:
https://www.agora.io/en/blog/building-a-video-calling-app-using-the-agora-sdk-on-expo-react-native/
The above article mentions this, but it should be noted that you will not be able to use Expo Go to test video call functionality since it requires native modules for the microphone and camera. I can speak from first hand experience that I have been able to use Expo Go for other features in the app, just not the Agora portions.
I am new on ReactJS and learning from scratch. I see some using babel and some are webpack to configure as well some use yarn package manager. So can you suggest me which is better to work with react.
I just curious about configuring reactJS environment thorugh which bundle or package manager?
babel is a transpiler, webpack is a bundler and yarn (or npm) is a package manager. These tools are for different purposes. And usually we use all of them together.
React has a very handy tool called Create React App. With this tool you don't need to configure babel and webpack by yourself so you can start to learn React easily.
You can start working with react using create react app(along with official react documentation) which will provide you app structure with no build configuration. So there is no need to worry about babel, webpack. you will get all configured with proper documentation. It's up to you to use yarn or npm as package manager.
This is best place to start up with ReactJS
In older versions you need to setup react with babel and webpack but now on current latest version you can directly start with Create React App
ReactJS Installation and startup guide
Just follows steps on this page, then run HelloWorld example which is best programs to start with any new programming language.