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'),
}
}
};
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.
How to convert expo app to react native cli? without re-coding it? I have a old expo app which I want to run but when i am running it with new react native version its showing too much errors now it has many deprecated functions is their any way to convert that app to react native cli? or any way to run that project without expo go? because expo go dont support SDK version 37
It seems like you can convert your expo project to a react-native-cli project using expo eject.
You should check out #deadcoder0904's answer to this question: Convert Expo project to Original React Native project
But, I'd definitely make a backup of your project before trying such things. Because this is a one way fix and we should be maintaining a older version in case of disaster.
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 trying to modify a react native boilerplate so that I can be run on Android platform.
I installed the expo package and added an index.js file on the root directory. But when I run the android code, it raised Can't find variable: require on the bundling phase
I uploaded my code here. Does anyone have an idea what I missed here?
resetting the cache worked for me.
On expo
expo r -c
for pure react native
react-native start --reset-cache
For those whose cache clearing didn't work. Try deleting .bablerc file. It has its own ways of effecting cache. My issue was only resolved after i deleted this.
I came across this when i was porting my react native app to web using react-native-web .
Platforms:
expo
react native
react native web
You should import your server.default in es6 style. require is a node.js method, in es6 modules you should use import instead. See here for more info on the usage of import.
Here you did
const newApp = require('./server').default;
When you should have
import {default} from './server'
I have little bit queries about detach expo app :
Am done app requirement but i have one thing that support only react native.
So i read about detach expo app and i think its mean if you done your coding in expo app and after detach you got android or ios folder and then copy these two folder and paste into react native project and then run command npm install.
But in above query i have one question in my mind .
Is expo coding that i done is available and its working as expo app in react native app or not ?
And now am continue coding after detach expo app in react native like add native module in react native app.
Detach or in actual terms, ejecting of your expo, in a React-Native project is a one way function. You cannot go back to the original setup once you eject.
After you eject, you get vanilla react native structure, which means separate folders for iOS and Android. This also means you lose access to expo API's you previously used. You can code or keep working on your project the same way as you were working before ejecting the app. Only your expo API's will change(if you have made use of them). Rest of your work flow will remain the same.