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.
Related
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.
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'm trying to understand the development process of React-Native, so I've found information about Metro, And then I've read/watch this Metro video):
Metro is the development platform for React Native and it does that by
exposing an HTTP server so clients, in this case, emulators can
communicate with it and it also exposes a Websocket server so it can
push updates into the clients.
The docs talk about the "React Native Packager" (now called Metro, according to the video) which runs on port 8081, so that is the HTTP server that starts when we type react-native run-android for example?
Regarding the Websocket I still need to read more.
The documentation says we're running our JavaScript code in two environments, depending if we're in debug mode or not, which I understood. But this article confused me a little bit, says:
No. 4 You Code Does Not Run on Node.JS: The JavaScript runtime you’ve got is ether JavaScriptCore (non-debug) or V8 (debug). Even
though you can use NPM and a node server is running on the background,
your code does not actually run on Node.JS. So you won’t be able to
use of the Node.JS packages. A typical example is jsonwebtoken, which
uses NodeJS’s crypto module.
And, then I've read things like:
React Native uses Node.js, a JavaScript runtime, to build your
JavaScript code.
Node.js is a server-side JavaScript runtime environment. React
Native ships with some tools that are written for Node.js.
Node.js is an open source platform built on Chrome's JavaScript
runtime; it offers a way to easily build fast, scalable
programs. Node.js allows you to run JavaScript in Terminal, and helps
create modules.
In this article, it says:
Download node.js from nodejs.org. This JavaScript runtime gives you
access to npm, which is a convenient tool created by the node.js
project that you can use to manage open source packages. Make sure
that you download the latest LTS (Long Term Support) version of
node.js. Also included with this download is a development server
called the Metro bundler, which provides live updates when debugging.
So:
The role of Node.js in RN is to only access npm and manage the packages? and is Metro is includes in Node.js? Am I missing/confusing something? Thank you.
There are four types of JavaScript you'll write in todays environments:
1) Clientside browser JavaScript:
That's what gets sent to webbrowsers when they visit your webpage, it then gets executed in the browser at the clientside. As you want the JS to load fast and run on all kinds of browsers, you usually use transpilers to turn the modern ESnext you write into a minified version with better support.
2) Clientside native JavaScript:
Most devices do have a native JS runtime, therefore you can ship JS files with your Android / iOS / Desktop application and then start them there. These engines also support adding hooks from JavaScript into your native code, that's how React Native does provide it's APIs.
3) Serverside NodeJS JavaScript:
NodeJS is a runtime you'll use to run servers.
4) Buildscripts running on NodeJS:
You can use JavaScript to generate JavaScript files. That's how you bundle the files for (1) and (2) (maybe also (3)).
Now metro is a serverside buildscript (on NodeJS) that you can use to either a) start a server that serves your JS as a webpage (1 & 3), or b) that bundles your JS in a native App that you can install on your device (2).
The role of Node.js in RN is to only access npm and manage the packages?
No. metro is itself a package that you then run on NodeJS.
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 building a RN project with "create-react-native-app" and "Expo". So how it is possible to run on Android & Ios device? How i can generate APK file? I am using sublime text 3 for writing code.
If you don't mind opening your app through the Expo app on real devices, all you need is to publish it onto the Expo ecosystem. Read more about publishing.
If you do mind that extra step and want to go the normal way, you need to create a standalone app for distribution:
When you’re ready to distribute your app to end-users, you can create
a standalone app binary (an ipa or apk file) and put it in the iOS App
Store and the Google Play Store. See the full guide to building a
standalone app.
Source