I am developing an app using React-Native, and I need to add a background service to check notifications. And I have tried almost all the solutions including Headless JS in the internet and I still couldn't make it. Maybe I’m doing it in a wrong way. Can anybody suggest me anything?
(Even when the app is not open)
There are many packages to use which will help you achieve this.
As you have not mentioned any of the used packages ill suggest some:
https://hackernoon.com/easy-os-background-tasks-in-react-native-bc4476c48b8a
https://www.npmjs.com/package/react-native-background-job
https://www.npmjs.com/package/react-native-background-task
I have used following packages for a Radio app in React native.
the following packages helped me achieve all the background related activites even when the app was minimized and another app was used(App running in background process).
"dependencies": {
"mobx": "^4.1.1",
"mobx-react": "^5.0.0",
"native-base": "^2.11.0",
"react": "16.6.3",
"react-native": "0.58.6",
"react-native-gesture-handler": "^1.0.15",
"react-native-swift": "^1.2.2",
"react-native-track-player": "^1.1.2",
"react-navigation": "^3.3.0"
},
Related
Following along with this tutorial and specifically this chunk of code causes a complete freeze up of the UI however, only when I tap within the TextInput to type (no on screen keyboard even pops up). Otherwise, the code runs just fine so I suspect it has everything to do with this TextInput somehow.
I'm running this code on a Mac within an iPhone 13 iOS 15.4 simulator. This is an Expo managed project but while following these setup instructions, the only command that did not work for me was npx pod-install ios (the error I got was "CocoaPods is not supported in this project"). In looking this up I found this SO answer which top answer said "because you are building your React-Native project with Expo", so I figured it was okay to ignore but maybe this is causing the freeze up?
No errors appear in the console where I run npm start, and no warnings/errors show up in the simulator so I don't even really know what to google. The only thing I can do is force quit the app which brings up that the incident will be reported to Apple but that's it. Below are my dependencies from my package.json, thanks for any help ahead of time:
"dependencies": {
"#react-navigation/native": "^6.0.8",
"#react-navigation/native-stack": "^6.5.2",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-web": "0.17.1"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
When I run react native project using expo I got this error "This project uses SDK 38.0.0 but this version of Expo Go only supports the following SDKs: 43.00, 42.0.0, 41.0.0, 40.0.0. To load the project, it must be updated to a supported SDK version or an older version of Expo Go must be used"
I already installed all my needed packages in the project so how to solve it?
"dependencies": {
"#eva-design/eva": "^2.1.1",
"#react-navigation/drawer": "^6.1.8",
"#react-navigation/native": "^6.0.6",
"#react-navigation/native-stack": "^6.2.5",
"#ui-kitten/components": "^5.1.1",
"expo": "~38.0.8",
"expo-status-bar": "^1.0.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "1.6.0",
"react-native-reanimated": "1.9.0",
"react-native-safe-area-context": "3.0.7",
"react-native-screens": "2.9.0",
"react-native-svg": "12.1.0",
"react-native-web": "~0.11.7"
},
You have to upgrade your expo SDK to latest one
use
expo upgrade
But if you have some packages which are depreciated then you don't have any option you have to create new expo project with and face little bit of efforts to rearrange them all
You'll need to update your version of the Expo SDK using the "expo upgrade" command.
This error is saying that your SDK version should be 43 down to 40, but your current version, as listed in the dependencies, is 38.0.8
Here are some resources for upgrading your version of the SDK from the official docs:
https://docs.expo.dev/workflow/upgrading-expo-sdk-walkthrough/
Note that they recommend upgrading your version of the SDK incrementally, so be cautious when performing upgrades as it could break your app if done carelessly.
I have a problem that I can't solve: I'm doing a development that has to be with this react and react-native versions
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
To avoid warnings in the Apple Store by hand this works like a charm:
https://docs.google.com/document/d/1o-wTwf1R8606wF8VloGxccjOIdTmJC0hSYysFgasQ7g/edit
but i'm unable to do it programatically
https://www.gitmemory.com/issue/react-native-community/react-native-webview/819/532829030
https://github.com/react-native-community/react-native-webview/issues/819
As an alternative option and until I can use a correct version of react-native ... Could anyone tell me if is possible to generate my own implementation of react-native without UIWebView libraries? Could that be possible?
I mean, i'm unable to "clean" UIWebView in the post_install executing pod install. I would like to do a npm install but without UIWebView libraries, with a customized react-native 0.59.9 implementation.
Thank you very much in advance and greetings.
UPDATE
Is possible to define a folder in the package.json file? Something like
"dependencies": {
"#lingui/react": "^2.7.4",
"#react-native-community/async-storage": "^1.2.1",
"axios": "^0.18.0",
"base-64": "^0.1.0",
"expo": "^27.1.1",
"intl": "^1.2.5",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.11",
"lottie-react-native": "^2.6.0",
"moment": "^2.24.0",
"react": "16.8.3",
"react-intl": "^2.8.0",
**"react-native": "mypath/my_0.59.9_react-native",**
PS It is the first time that I participate in Stackoverflow (although I have entered millions of times), I hope I have posed the question correctly.
Yes you can, I have done it with react-native 0.59.8 using patch-package.
What you need to do is:
Follow the instructions to install patch-package in your project.
Modify the react native Objective-c code and remove the UIWebView (for 0.59.8 I simply deleted the content of RCTWebView.h, RCTWebView.m, RCTWebViewManager.h and RCTWebViewManager.m).
Run the patch-package utility to create the patch and commit it to your repo.
For example, here are the patches that I created for react-native 0.59.8
Cheers!
I have built project react-native (on window) . When I connected device and run app ( react-native run-android) or reload app it just show blank-space, but if I pressed ctrl+S in visual code, app would fast refresh and run success.
If I disconnected device, app would show blank screen again. How do I run app success without connecting device ?
This is my version react-native
"dependencies": {
"#react-native-community/viewpager": "^2.0.2",
"firebase": "^7.2.3",
"react": "16.9.0",
"react-native": "0.61.3",
"react-native-gesture-handler": "^1.5.0",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "1.0.0-alpha.23",
"react-native-swipe-gestures": "^1.0.4",
"react-native-swipeable": "^0.6.0",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"realm": "^3.4.2",
"rn-fetch-blob": "^0.11.2"}
There are 3 ways :
1.) You have to build an APK of app from android, if you want to run the app without using react-native run-android command, but it would be a static app if you dont what to develop further.
2.) You can use hot refresh and hot reload.
3.) By using ADB connection.
I am guessing you are disconnecting your device, and hoping to see the same functionality without generating signed apk. Is that so?
I have a react-native app which is working properly for a long time. But after something is happened, i don't know what it is, my app redux store data is not cleaning when i close the app.
Is someone here experiencing same problem? Am i doing something wrong?
By the way, the ios app is working fine. It's only in android.
I didn't share any code with you because everything was working fine before. If you want to take a look into code, just tell me.
Here is a video about my problem: https://streamable.com/wwbsh
From another question on stackoverflow.
However if the app is shut down, and the code re-runs it will be
loaded with your default redux state.
But my state is not loaded with my defaults.
Thank you.
"react": "16.3.1",
"react-redux": "^5.1.1",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
After each app launch redux state should be reloaded with the defaults unless you're persisting your state using redux-persist