Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all 17353 articles
Browse latest View live

Can't show Image in React Native

$
0
0

I'm using react-native 0.28.0

I'm trying to show an image on iPhone simulator according to this tutorial: Introduction to React Native: Building iOS Apps with JavaScript | Appcoda

var styles = StyleSheet.create({image: {    width: 107,    height: 165,    padding: 10  }}var imageURI = 'http://books.google.com/books/content?id=PCDengEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api'

Then in the render() function, I add this:

<Image style={styles.image} source={{uri:imageURI}} />

The space allocated for the image is there, but the image is not shown.


Why is there a difference in header behaviour between IOS and Android - Expo Application/React Navigation

$
0
0

Good day!

I was wondering if someone had any insights to this differing header behaviour between IOS (iPhone 6, version 12) and Android (Pixel 4, API 26)? On Android the icon is correctly at the start of the header but on IOS it is stuck in the middle.

AndroidIOS

const Header = () => {return(<View style={{flex:1, flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', backgroundColor:'#ff00ff'}}><MaterialIcons name="menu" size={30} color="#ffffff" /></View>)}

I am not sure if it is relevant but this component is used as a header title in a stack navigation used in React Navigation.

const StackNav = ({name, component}) => {const Stack = createStackNavigator()return(<Stack.Navigator><Stack.Screen            name={name}            component={component}            options={{                headerTitle: props => <Header/>,                headerStyle: {                    backgroundColor: '#043E22',                 },            }}        /> </Stack.Navigator>)}

Thank you!

React Native DuplicateError: Duplicated files or mocks

$
0
0

After updating xCode I am facing the below error from a week. I am not able to run app on device. I dont think the issue is with xcode because even if I try to run on android device the same issue occurs.

The issue occurs when we run npm start also with reset option the same error occurs.

The only option is to run on android device after deleting ios build folder.

The error

The following files share their name; please adjust your hasteImpl:    * <rootDir>/node_modules/react-native/package.json    * <rootDir>/ios/build/oleo/Build/Products/Debug-iphoneos/oleo.app/assets/node_modules/react-native/package.jsonFailed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info    at setModule (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:620:17)    at workerReply (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:691:9)    at processTicksAndRejections (internal/process/task_queues.js:93:5)    at async Promise.all (index 668) {  mockPath1: 'node_modules/react-native/package.json',  mockPath2: 'ios/build/oleo/Build/Products/Debug-iphoneos/oleo.app/assets/node_modules/react-native/package.json'}(node:8630) UnhandledPromiseRejectionWarning: Error: Duplicated files or mocks. Please check the console for more info    at setModule (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:620:17)    at workerReply (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:691:9)    at processTicksAndRejections (internal/process/task_queues.js:93:5)    at async Promise.all (index 668)(node:8630) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)(node:8630) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Package.json

{"name": "oleo","version": "0.0.1","private": true,"scripts": {"start": "react-native start","test": "jest","lint": "eslint .","create-bundle-ios": "react-native bundle --platform ios --dev true --entry-file index.js --bundle-output ios/main.jsbundle","create-bundle-android": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"  },"dependencies": {"@react-native-community/async-storage": "^1.9.0","@react-native-community/netinfo": "^5.8.0","@react-native-community/push-notification-ios": "^1.1.1","@react-native-firebase/analytics": "^6.7.1","@react-native-firebase/app": "^6.7.1","@react-native-firebase/auth": "^6.7.1","@react-native-firebase/firestore": "^6.7.1","@react-native-firebase/messaging": "^6.7.1","@react-native-firebase/storage": "^6.7.1","accordion-collapse-react-native": "^0.2.10","lodash": "^4.17.15","md5": "^2.2.1","moment": "^2.24.0","react": "16.8.6","react-native": "0.60.5","react-native-chooser": "^1.7.0","react-native-datepicker": "^1.7.2","react-native-draggable-flatlist": "^2.3.2","react-native-exit-app": "^1.1.0","react-native-gesture-handler": "^1.6.1","react-native-image-crop-picker": "^0.25.3","react-native-image-view": "^2.1.8","react-native-material-dropdown": "^0.11.1","react-native-modal": "^11.5.6","react-native-pdf": "^6.1.1","react-native-phone-input": "^0.2.4","react-native-popup-dialog": "^0.18.3","react-native-push-notification": "^3.2.1","react-native-reanimated": "^1.8.0","react-native-screens": "^2.7.0","react-native-snackbar": "^2.2.0","react-native-swiper": "^1.6.0","react-native-webview": "^7.4.2","react-navigation": "^4.3.8","react-navigation-stack": "^1.10.3","rn-fetch-blob": "^0.11.2"  },"devDependencies": {"@babel/core": "^7.9.0","@babel/runtime": "^7.9.2","@react-native-community/eslint-config": "^0.0.5","babel-jest": "^24.9.0","eslint": "^6.8.0","jest": "^24.9.0","metro-react-native-babel-preset": "^0.56.4","react-test-renderer": "16.8.6"  },"jest": {"preset": "react-native"  }}

I have deleted multiple times node modules, did a fresh install as well but the issue comes up every time.

How to use Lottie designs as background design

$
0
0

I am using ImageBackground But now i have to add lottie designs so i need to know how can i use lottie designs as the imagebackground

<LottieView        source={require('../path/to/animation.json')}        colorFilters={[{          keypath: "button",          color: "#F00000"        },{          keypath: "Sending Loader",          color: "#F00000"        }]}        autoPlay        loop      />

if lottie design available then show design. Otherwise will show imagebackground image in this. if image not available then show a background color. So provide me resolution for this.

React Native - `require()` statement exception handling

$
0
0

TL;DR: I want to be able to require a module in react-native and handle the exception myself in case the module does not exist (instead of displaying the RedBox).


I am using moment.js's logic to choose the most suitable locale from its library of presets (https://github.com/moment/moment/tree/develop/locale), when given a requested locale.

For example, if asked for en-us, and it was not found, it will fall back to en and so forth. The code for this logic (chooseLocale, loadLocale) can be found here: https://github.com/moment/moment/blob/develop/src/lib/locale/locales.js

Basically, it tries to require the given preset. If it does not exist, it gets en exception from the require statement, catches it and moves on to the next option.

Now, my issue is trying to use this logic with react-native. The require statement is actually implemented with react-native's guardedLoadModule which handles the exception (displays red screen). In my opinion, moment's logic is not hurt by this logic, hence I would like for the RedBox to not display.

Any thoughts?

After google sign Safari redirect me to my app, but i see only loading screen. (aws amplify, react native, expo)

$
0
0

i try to test my application on ios using TestFlight, AWS Amplify, React Native, expo. I press google sign in button and Safari redirect me to my app, but i see only loading screen. I think this is due to the fact that the search field is empty during a redirect to my application.

Maybe someone has already encountered this. I will be glad for any help, have a nice day!

Expo Vector Icon - how to change background color?

$
0
0

I am using Expo vector Icon in my app with React Native. I'm using icons as below and it works fine for all the props. However, I've been trying to change the background color and it doesn't change as expected. I've checked the docs and all the properties work as expected except for backgroundColor. Any idea why it isn't working?

<AntDesign       name={name}       size={size}       color={color}       iconStyle={iconStyle}       backgroundColor="red"/>

Render many charts without lags on React Native

$
0
0

I'need to show user feed with items where every item contain a chart.Now I use react-native-svg-charts:

<LineChart style={{ height: 150, position: 'relative', left: -20 }} data={data} curve={shape.curveNatural} svg={{ stroke: chartColor1, strokeWidth: 5 }} contentInset={{ top: 20, bottom: 20 }} showGrid={false} numberOfTicks={0} key={props.id}>

But when I load more then 50 items performance of the app fall down to 10-15 fps.

I think it because of many SVG's on page. Which solution do you think should I use to avoid this?


React Native Push Notifications, FCM says token is invalid on iOS only (Android works)

$
0
0

We have a React Native App which is trying to send push notifications using the Firebase Cloud Messaging Service. We are testing this using Insomina.

To do this, we are using a package called “react-native-push-notification” by zo0r.We’ve been able to obtain an iOS apn token from a real life apple device. We are then able to successfully send a POST request to this url:

https://iid.googleapis.com/iid/v1:batchImport 

to convert the apns token into a registration token for Google’s firebase cloud messaging platform.

However, when we try and send a message using the converted token, by sending a POST request to this endpoint:

https://fcm.googleapis.com/fcm/send

using this JSON payload:

{"direct_book_ok": true,"to": "fTiQ5mg266o:APA91bGQN1s9sYJh9U_B6h1vuwAjpQVrPIJFnCWWsiv4PgKTCOCqLiKIdAD6ls48f-dBbnV3tOdc6NvTScXSRJYrXNHz_5QonSFraEau5jKSJPcw8HYeOb2YnutC39TlaIlKBnD3FpSx","notification": {"title": "Breaking News","body": "New Story available."              },"priority": "high"}

AND these headers:

Authorization: key=<OUR_SECRET_KEY> and Content-Type: application/json

The Google API responds with the following error, indicating that the notification has failed because of an “invalid argument”.

{"multicast_id": 3503657462083604439,"success": 0,"failure": 1,"canonical_ids": 0,"results": [   {"error": "InvalidParameters: RpcError:INVALID_ARGUMENT"   } ]}

How would we remedy this? We’ve tried both sandbox=true and sandbox false.

Can't show Image by URI in React Native iOS Simulator

$
0
0

I'm using react-native 0.28.0

I'm trying to show an image on iPhone simulator according to this tutorial:

Introduction to React Native: Building iOS Apps with JavaScript | Appcoda

var styles = StyleSheet.create({image: {    width: 107,    height: 165,    padding: 10  }}var imageURI = 'http://books.google.com/books/content?id=PCDengEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api'

Then in the render() function, I add this:

<Image style={styles.image} source={{uri:imageURI}} />

The space allocated for the image is there, but the image is not shown.


However, if I use local image instead, the image will be shown.

var Picture = require('./content.jpeg')

In render() function:

<Image source={Picture} style={styles.thumbnail} />

How can I show picture using URI as source?

React Native - Deep linking from Google app in iOS not working

$
0
0

I noticed that my app does not open when tapping on a link from the result page of the Google app on iOS.

I have configured Universal links for iOS and Android and also have branch.io working.

Works well as expected on Chrome and Safari browsers. But not on Google.app.

I tried to search for a facebook profile on the 'Google app search' and tapped on a result. It actually navigated into the web page (profile), and then opened the native Facebook app (depplinked into the profile page).

So I was wondering what I had missed. Was it a <meta /> tag that was missing on the web page? Eg. in https://www.example.com/item/123

Or something I need to add in the Xcode configurations?

Example scenario:

Domain    - https://www.example.comBundle Id - com.example.appLink      - https://www.example.com/item/123
// Xcode => Associated Domains => Domainsapplinks:www.example.com
// File: apple-app-site-association{"applinks": {"apps": [],"details": [            {"appID": "XYZXYZX.com.example.app","paths": ["/item/*"                ]            }        ],"components": [            {"/": "/item/*"            }        ]    }}

Versions:

react: 16.13.1react-native: 0.63.3react-navigation: ^4.4.3react-native-branch: ^5.0.1

Google ap

How to setup multiple environment Dev and Prod for React Native Typescript?

$
0
0

In My application, I am using two different API's for development and production. I want to Implement Like whenever If I pass the command yarn dev iOS then build will generate with development API, Same as well If I pass the command yarn prod iOS build will generate with production API. How to achieve this?

I have tried using react-native-dotenv but not getting much clear idea.

How to check if keyboard is displayed in detox tests for iOS and android?

$
0
0

I am passing a search term in the input field, keyboard will open up in the device.

How can I assert that Keyboard opened up in the iOS and android device

Simulator is slow in Xcode 12.4

$
0
0

After upgrading my Mac to Big Sur 11.2 and Xcode to 12.4 , I noticed that the simulator is running very slowly. it can take more than 5 seconds to execute a single command.I've looked up a couple of solutions but nothing worked for me. my 'Slow animations' is not checked.also running the images on a low quality is not a good option.The simulator was working fine before the upgrade and nothing changed in my code.I'm running iPhone 11 iOS 14.4 simulator.

How to listen App launch and close in React Native?

$
0
0

I need to track some logs event(only once) when App launch and close.

First I do this in Home screen componentDiMount(), but it will be instantiated several times in some case, causing repetitive launch event log.

=============== Edit =================

AppState can only listen background and active event.

When closing app on Android (press back key or close in recents app menu), it actually back to background. It takes the app back to active from background when reopen the app. Which is the same as toggle app between background and active(not close)

So I can't determine whether it is first launch or toggling app status using AppState


fastlane match generate new certificate with push notifications enabled

$
0
0

I'm a bit confused on how I'm supposed to add push notification capabilities to an app where I have generated provisioning profiles/certs using fastlane match

I'm trying to run my device in development after enabling and setting up push notifications but keep seeing the error that the capabilities are not supported by the development provisioning profile that match generated for me

I have tried a number of times to nuke the development cert and generating a new one but it continues to create a certification without push notification capabilities enabled

What is the process I am supposed to go through to add push notifications and generate a new provisioning profile/certificate with push notification capabilities?

How to update my function with image Picker on react native ios

$
0
0

I have the old version of image picker but i don't know how to update my function. Can you help me please ?

Also my function for image picker

function App () {    const [filePath, setFilePath] = useState({});    const chooseFile = () => {      let options = {        title: 'Select Image',        customButtons: [          {            name: 'customOptionKey',            title: 'Choose Photo from Custom Option'          },        ],        storageOptions: {          skipBackup: true,          path: 'images',        },      };      ImagePicker.showImagePicker(options, (response) => {        console.log('Response = ', response);        if (response.didCancel) {          console.log('User cancelled image picker');        } else if (response.error) {          console.log('ImagePicker Error: ', response.error);        } else if (response.customButton) {          console.log('User tapped custom button: ',            response.customButton          );          alert(response.customButton);        } else {          let source = response;          // You can also display the image using data:          // let source = {          //   uri: 'data:image/jpeg;base64,'+ response.data          // };          setFilePath(source);        }      });    };

my error is : TypeError: undefined is not a function (near '...ImagePicker.showImagePicker...')

React Native init specific version

$
0
0

I upgraded my latest project to React Native 0.19 and instantly the video no longer works. How can I create a new project with a specific version? I want to init a new project at version 0.18.1. I did some google searches but couldn't find anything about this.

$ react-native init newproject --verbose

I'm guessing I need to add the word @18.1 in there somewhere but can't get that to work.

Read ALL SMS in inbox or Send it to Server in React NATIVE

$
0
0

I am building an app that requires the functionality of reading SMS from the inbox. It's a kind of app that Microsoft built known as SMS organizer. I'm trying to build it for the local crowd and I'm using react-native to do the same. I read many libraries but none seem to be helpful or informative for my cause.

Anyone has any idea for how I can accomplish the same.PS- I'm aiming to do it for both androids as well as ios.

React-Native Offline Bundle - Images not showing

$
0
0

I have a React-Native app I'm trying to deploy in Release mode to my phone. I can bundle the app to the phone. Database, Video and audio assets are all in there but no images are showing in the UI.

I have done the following to 'bundle' my app:

  1. in the project folder in Terminal run react-native bundle --platfrom ios --dev false --entry-file index.ios.js --bundle-output main.jsbundle
  2. Drag the reference to the main.jsbundle file into XCode under myapp folder
  3. In XCode, open AppDelegate.m and uncomment jsCodeLocation = [[NSBundle mainBundle]…
  4. Open Product > Scheme > Edit Scheme then change Build Configuration to Release
  5. Select myapp under the project navigator and then:under TARGETS: myappTests>Build Phases>Link Binary With Librariespress +select Workspace>libReact.a and Add

When I try and compile in XCode with the ../node_modules/react-native/packager/react-native-xcode.sh setting in myapp > targets > myapp > Bundle React Native code and images it fails with error code 1.

I've seen LOADS of posts on this and I've tried:

  • to check Run script only when installing- the app then installs but with no images
  • adding source ~/.bash_profile to react-native-xcode.sh - the app build fails

Any help would be greatly appreciated!

Viewing all 17353 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>