How do I integrate react-native-sensors to my project? - javascript

I found a useful library to detect position of mobile phones, but I'm not sure how to integrate it to my project as I'm new to both JavaScript and React Native. I tried making it into a class so I can just call it like this <MotionSensor /> and monitor what it does thru the console. And I'm trying to do this without touching the Android and iOS native code so my code can work for both.
You can take a look at my App.js here.
I use the combination of create-react-native-app and Expo.
Any help is greatly appreciated!

Related

Turning NextJS website to desktop app: Electron, React-Native or React-Desktop?

I've just learnt ReactJS and am currently using it develop an application with NextJS. I plan to make it available as a desktop application, too.
I've come across Electron, React-Native and React-Desktop, but I am uncertain which would be the best choice. I would prefer a solution which allows me to use most of the code I've already written (so React-Native probably isn't the best choice?)
Also: Does the use of NextJS make it harder to turn it to a desktop application (since there aren't really URL paths in a desktop app)? Is it possible to somehow automatically "convert" for example Link components, so they work in a Desktop app? Or are NextJS features only usable when the code runs in a browser (which would mean, that I may use my React Components, but not the NextJS site structure)?
Thank you for your time.
You should try https://github.com/saltyshiomix/create-nextron-app
basic-javascript example
$ npx create-nextron-app my-app

WHERE do you set up the applicationIconBadgeNumber?

Does anyone know WHERE do you set up the applicationIconBadgeNumber for React Native / Expo application for iOS & Android?
Im using React Native, Visual Studio Code and Expo.
Like, on WHICH Page / File, etc ?
I cannot seem to find: [UIApplication sharedApplication].applicationIconBadgeNumber
If you can please list the Steps to get this working, and any installs (if needed).
I already have Push Notifications working on my App, but Im trying to set this up now.
Any help would be greatly appreciated.
Please help!
Does anyone know WHERE do you set up the applicationIconBadgeNumber for React Native / Expo application for iOS & Android?
Expo API is pretty clear about this, I googled your question and it linked me to it:
Expo.Notifications.setBadgeNumberAsync(number)
Like, on WHICH Page / File, etc ?
This is a pretty open ended question. You could link setBadgeNumberAsync to your redux in an action.
Or just put it anywhere I guess 🤷‍♀️ it's a static method that excepts a number, I would use the redux approach though! 💙

Is it ok to make a ract native app only in javascript?

So... I just started to learn React Native to create an android app, and I am a little confused, should I only use java script for the visual part with react and the rest of the app with java ?
Or can I make the whole app with javascript and some Node modules ?
You can write everything in Javascript for Android and iOS. That's the purpose of react-native. See an Android code example here: http://code.tutsplus.com/tutorials/creating-a-dictionary-app-using-react-native-for-android--cms-24969
But you can also mix in native Android Java classes and then import then call them in your JS code. This is useful if you want to use components which are currently not yet implemented in react-native. Check out this example to read more about using native components: https://facebook.github.io/react-native/docs/native-modules-android.html

How to integrate objective C or swift programming code into cordova ios app?

I have some objective C code. I need to integrate it into my cordova project.
How can I run that code in my Cordova IOS app?
Your question is a little vague. But to get you pointed in the right direction:
Open your project in finder and navigate to platforms>ios>[project-name]>Classes.
Here you will find AppDelegate and ViewController files. These are written in objective C. AppDelegate handles a lot of the central processes of your app.
If you want to add something specific in ObjectiveC you have to write a plugin. Here's the doc about it : https://cordova.apache.org/docs/en/5.4.0/guide/hybrid/plugins/index.html
Once you've integrated your new plugin into your cordova app, you just have to execute your native callback from the javascript code. It works the same way as an official plugin.
What exactly do you want to add in ObjectiveC, are you sure that you can't do it from the webView ? (I mean in JS and not as native code)

Phonegap on Android: getting Drawables/AppIcons back into Javascript environment for display in "browser"

I'm building an Android based WebApp using PhoneGap, and trying to get the app icons of several currently installed applications back into the Javascript environment for displaying in the "browser".
Getting hold of the icons in the ANdroid layer is no problem. I've done that with code similar to this:
Drawable myNewIcon = myResolveInfoInstance.loadIcon(mycontext.getPackageManager());
... but I'm struggling with working out how to get the icon back into the Javascript callback so that I can place it into the "webpage".
If anyone can give me a tip or two on how to achieve this, it would be very much appreciated. It doesn't seem like it should be too difficult...!?
thanks.
If these drawables are going to be used purely on the web side of your project then putting them in the assets folder is the best idea. Then they can be accessed via:
file:///android_asset/www/images/icon.png
for instance.

Categories

Resources