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

React native bug RCTFatal

$
0
0

What can be wrong here?

Failed to call function, __fbBatchedBridge is undefinedRCTFatal-[RCTCxxBridge handleError:]__21-[RCTCxxBridge start]_block_invokeinvocation function for block in facebook::react::(anonymous namespace)::RCTObjcExecutor::RCTObjcExecutor(id<RCTJavaScriptExecutor>, void (NSError*) block_pointer, std::__1::shared_ptr<facebook::react::MessageQueueThread>, std::__1<facebook::react::ExecutorDelegate>)__58-[RCTWebSocketExecutor _executeJSCall:arguments:callback:]_block_invoke-[RCTWebSocketExecutor webSocket:didReceiveMessage:]__33-[RCTSRWebSocket _handleMessage:]_block_invoke_dispatch_call_block_and_release_dispatch_client_callout_dispatch_lane_serial_drain_dispatch_lane_invoke_dispatch_workloop_worker_thread_pthread_wqthreadstart_wqthread

I am trying tu build react native app on osx device in emulator.

npm run ios


How to save data of my screen on iOS simulator to local storage (react-native)

$
0
0

I am using react-native and expo. I have some data that is displayed on the screen (this is my second screen) such as:

 let item = state.myListData.length && state.myListData[0];let movie = (<View><Viewstyle={{flexDirection: 'row',backgroundColor: 'black',alignItems: 'center',}}><Text style={{ width: '50%', color: 'white' }}>{item.symbol}</Text><Text style={{ width: '10%', color: 'white' }} key={item.open}>{item.open}</Text><Textstyle={{width: '30%',color: 'white',backgroundColor: 'red',marginVertical: 5,paddingHorizontal: 10,borderRadius: 10,}}key={item.close}>{item.close}</Text></View><View style={styles.bottomdata}><Text style={[styles.text, { alignSelf: 'center' }]} key={item.name}>{item.name}</Text><View style={styles.row}><View style={styles.rowItem}><Text style={styles.text}>OPEN</Text><Text style={styles.text}>{item.open} </Text></View><View style={styles.rowItem}><Text style={styles.text}>CLOSE</Text><Text style={styles.text}>{item.close}</Text></View></View><View style={styles.row}><View style={styles.rowItem}><Text style={styles.text}>LOW</Text><Text style={styles.text}>{item.low} </Text></View><View style={styles.rowItem}><Text style={styles.text}>HIGH</Text><Text style={styles.text}>{item.high}</Text></View></View><View style={styles.rowItem}><Text style={styles.text}>VOLUME</Text><Text style={styles.text}>{item.volumes}</Text></View></View></View>);

How do I save this data to my screen even though if user goes back to first screen and comes back to second screen it should still be there, but it disappears at the moment since I am not sure how to store it in local storage.

I looked up online and wrote this:

const x = {key:"value"}savingdata   = () => {if (movie){let storeData = async () => {  try {    await AsyncStorage.setItem('x',      movie    );    console.log(storeData);  } catch (error) {    // Error saving data    console.log(error);  }};}};

This doesn't work at all. I am new to saving data so I am not sure how to do it. If someone can please help me?

That's my whole code for second screen:

import React, { useState, useEffect } from "react";import { AsyncStorage } from "react-native";import {  TouchableWithoutFeedback,  Keyboard,  FlatList,  TextInput,  Button,  Text,} from "react-native";import {  StyleSheet,  View /* include other react-native components here as needed */,} from "react-native";import { useStocksContext } from "../contexts/StocksContext";import { scaleSize } from "../constants/Layout";// FixMe: implement other components and functions used in StocksScreen here (don't just put all the JSX in StocksScreen below)export default function StocksScreen({ route, navigation }) {  const { ServerURL, watchList } = useStocksContext();  const [state, setState] = useState({    myListData: [],    _storeData:[]    /* FixMe: initial state here */  });  const { stuff } = route.params;  renderWithData = () => {    return fetch(`http://131.181.190.87:3001/history?symbol=${stuff}`)      .then((res) => res.json())      .then((json) => {        setState({          isLoaded: true,          myListData: json,        });      // console.log(state.myListData[0]);      });  };  useEffect(() => {    renderWithData();    savingdata();    // FixMe: fetch stock data from the server for any new symbols added to the watchlist and save in local StocksScreen state  }, [watchList]);  //let item = state.myListData[0];  let item = state.myListData.length && state.myListData[0];let movie = (<View><Viewstyle={{flexDirection: 'row',backgroundColor: 'black',alignItems: 'center',}}><Text style={{ width: '50%', color: 'white' }}>{item.symbol}</Text><Text style={{ width: '10%', color: 'white' }} key={item.open}>{item.open}</Text><Textstyle={{width: '30%',color: 'white',backgroundColor: 'red',marginVertical: 5,paddingHorizontal: 10,borderRadius: 10,}}key={item.close}>{item.close}</Text></View><View style={styles.bottomdata}><Text style={[styles.text, { alignSelf: 'center' }]} key={item.name}>{item.name}</Text><View style={styles.row}><View style={styles.rowItem}><Text style={styles.text}>OPEN</Text><Text style={styles.text}>{item.open} </Text></View><View style={styles.rowItem}><Text style={styles.text}>CLOSE</Text><Text style={styles.text}>{item.close}</Text></View></View><View style={styles.row}><View style={styles.rowItem}><Text style={styles.text}>LOW</Text><Text style={styles.text}>{item.low} </Text></View><View style={styles.rowItem}><Text style={styles.text}>HIGH</Text><Text style={styles.text}>{item.high}</Text></View></View><View style={styles.rowItem}><Text style={styles.text}>VOLUME</Text><Text style={styles.text}>{item.volumes}</Text></View></View></View>); const x = {key:"value"}savingdata   = () => {if (movie){let storeData = async () => {  try {    await AsyncStorage.setItem('x',      movie    );    console.log(storeData);  } catch (error) {    // Error saving data    console.log(error);  }};}};  return (<TouchableWithoutFeedback onPress={Keyboard.dismiss}><View style={styles.container}>      {movie}</View></TouchableWithoutFeedback>   );}

I want to save data in different class, if that possible, so my code is not messy. But, saving in the same class in okay as well whatever works. Any help is appreciated.

Faster mobile coding language for iOS and ANDROID

$
0
0

What's the faster (in development and in running process) mobile coding language, which are able to get user contact list, detect user sms confirmation when suscribing in the own app, be abe to use user camera (of corse after user validation), ... and all the functionality that the phone operating system provide, and which can build app for iOS and Android environment (to avoid creating app for iOS and another for ANDROID).

How to save the jsx data in my screen (ios simulator)

$
0
0

I have some data on my screen as you can see in the screenshot. When user clicks on first screen (it has some symbols with their name) it send them to second screen (screenshot below) and show the data related to that symbol.

Second screen

I can save the data by pressing the store button, but I want to display the jsx data so here it is movie. If user let's say click on symbol AAL (on first screen) it sends them to second screen and you AAL symbol with it's details at the bottom. Now user goes back to first screen and clicks on ABBV now we add ABBV at the top of second screen and show data related to it at the bottom of screen and so on. How can I do that?

My code:

import React, { useState, useEffect } from "react";import { AsyncStorage } from "react-native";import {  TouchableWithoutFeedback,  Keyboard,  FlatList,  TextInput,  Button,  Text,} from "react-native";import {  StyleSheet,  View ,} from "react-native";import { useStocksContext } from "../contexts/StocksContext";import { scaleSize } from "../constants/Layout";export default function StocksScreen({ route, navigation }) {  const { ServerURL, watchList } = useStocksContext();  const [state, setState] = useState({    myListData: [],  });  const { stuff } = route.params;  renderWithData = () => {    return fetch(`http://131.181.190.87:3001/history?symbol=${stuff}`)      .then((res) => res.json())      .then((json) => {        setState({          isLoaded: true,          myListData: json,        });      // console.log(state.myListData[0]);      });  };  useEffect(() => {    renderWithData();    // FixMe: fetch stock data from the server for any new symbols added to the watchlist and save in local StocksScreen state  }, [watchList]);  //let item = state.myListData[0];  let item = state.myListData.length && state.myListData[0]; //that's what I want to store on my screenlet movie = (<View><Viewstyle={{flexDirection: 'row',backgroundColor: 'black',alignItems: 'center',}}><Text style={{ width: '50%', color: 'white',  fontSize: 18 }}>{item.symbol}</Text><Text style={{ width: '20%', color: 'white',fontSize: 18 }} key={item.open}>{item.open}</Text><Textstyle={{width: '34%',color: 'white',fontSize: 16,backgroundColor: 'red',marginVertical: 5,marginHorizontal:-10,paddingHorizontal: 35,padding: 4,borderRadius: 10,borderColor:"red",overflow:"hidden"}}key={item.close}>{item.close}</Text></View><View style={styles.bottomdata}><Text style={[styles.name, { alignSelf: 'center' }]} key={item.name}>{item.name}</Text><View style={styles.row}><View style={styles.rowItem}><Text></Text></View><View style={styles.rowItem}><Text></Text></View></View><View style={styles.row}><View style={styles.rowItem}><Text style={styles.label}>OPEN</Text><Text style={styles.text}>{item.open} </Text></View><View style={styles.rowItem}><Text style={styles.label}>CLOSE</Text><Text style={styles.text}>{item.close}</Text></View></View><View style={styles.row}><View style={styles.rowItem}><Text style={styles.label}>LOW</Text><Text style={styles.text}>{item.low} </Text></View><View style={styles.rowItem}><Text style={styles.label}>HIGH</Text><Text style={styles.text}>{item.high}</Text></View></View><View style={styles.rowItem}><Text style={styles.label}>VOLUME</Text><Text style={styles.text}>{item.volumes}</Text></View></View></View>);//right now just storing the json dataconst x ="key";const storeData = async (value) => {  try {    const jsonValue = JSON.stringify(movie)    console.log(jsonValue);    await AsyncStorage.setItem(x,jsonValue)    console.log("storing..");  } catch (e) {    // saving error    console.log("error storing...");  }} const getData =  async () => {  try {    const jsonValue = await AsyncStorage.getItem(x)    console.log(jsonValue);    return jsonValue != null ? JSON.parse(jsonValue) : null;  } catch(e) {    // error reading value    console.log("error getdata");  }}  return (<TouchableWithoutFeedback onPress={Keyboard.dismiss}><View style={styles.container}>      {movie}      {storeData}<Button onPress={storeData} title="Store items">Press me</Button><Button onPress={getData} title="get items">getdata</Button></View></TouchableWithoutFeedback>   );}

How can I store the movie on my screen?

Which is the best way to communicate from app to app in single device?

$
0
0

My idea is create Report Viewer application for both Android and IOS, (could be good on ReactNative also)

  1. BaseApp: open ReportApp via URL_Scheme to register BaseApp URL_Scheme
  2. ReportApp: send request to get json_spec to BaseApp
  3. ReportApp: read api from spec, and send request back to BaseApp get and display data (table, chart,...)

I find some technologies, that I think it could solve my problem:

  1. Inter Process Communication
  2. Android Intent
  3. Android Content Provider
  4. Or, May I use custom REST server on my app

Unsupported architecture error on initializing React Native app

$
0
0

It's so weird, yesterday morning everything works well, but after trying to install on a physical iOS device, I even cannot initiate a React Native project, right after the npx react-native init MyNewApp command I get this error:

clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/lib/libc++.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/lib/libc++.tbd (4 slices)ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/lib/libSystem.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/lib/libSystem.tbd (4 slices)clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]In file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:52:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv/errno.h:25:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/errno.h:31:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/errno.h:23:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/errno.h:72:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture#error Unsupported architecture ^In file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:55:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdio.h:107:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:33:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported#error architecture not supported ^In file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:55:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdio.h:107:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'; did you mean'__int128_t'?typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'; did you mean'__int128_t'?typedef __int32_t       __darwin_blksize_t;     /* preferred block size */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'; did you mean'__int128_t'?typedef __int32_t       __darwin_dev_t;         /* dev_t */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, or gid_t*/        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'; did you mean'__uint128_t'?typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */        ^/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'; did you mean'__uint128_t'?typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'; did you mean'__int128_t'?typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'; did you mean'__int128_t'?typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'; did you mean'__int128_t'?typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */        ^note: '__int128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */        ^note: '__uint128_t' declared here/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */        ^note: '__uint128_t' declared hereIn file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:55:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdio.h:107:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:43:9: error: unknown type name '__uint32_t'; did you mean'__uint128_t'?typedef __uint32_t      __darwin_wctype_t;        ^note: '__uint128_t' declared hereIn file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:55:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdio.h:107:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:75:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types/_va_list.h:31:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/machine/types.h:37:2: error: architecture not supported#error architecture not supported ^In file included from ../fsevents.cc:6:In file included from ../../nan/nan.h:55:In file included from /Users/amerllica/Library/Caches/node-gyp/12.18.0/include/node/uv.h:55:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdio.h:107:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:75:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types/_va_list.h:32:9: error: unknown type name'__darwin_va_list'typedef __darwin_va_list va_list;        ^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [Release/obj.target/fse/fsevents.o] Error 1gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2gyp ERR! stack     at ChildProcess.onExit (/Users/amerllica/.nvm/versions/node/v12.18.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)gyp ERR! stack     at ChildProcess.emit (events.js:315:20)gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)gyp ERR! System Darwin 19.5.0gyp ERR! command "/Users/amerllica/.nvm/versions/node/v12.18.0/bin/node""/Users/amerllica/.nvm/versions/node/v12.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js""rebuild"gyp ERR! cwd /Users/amerllica/.npm/_npx/15892/lib/node_modules/react-native/node_modules/fseventsgyp ERR! node -v v12.18.0gyp ERR! node-gyp -v v5.1.0gyp ERR! not ok

I tried many ways, even I uninstall XCode and then re-install XCode. set everything from scratch but I get this error for initializing React Native application.

The Development Server Returned Error Code:500(React Native)

$
0
0

Hello I am pretty new to react native I am working on this project it is a Sign In/Sign Up page for a project i am working on enter image description hereRunning through expo,Running this on a physical device.I have tried other options available on stack overflow none of them at least worked for me

***App.js***import React from 'react'import{StyleSheet,Text,View}from 'react-native'import RegForm from './app/Components/RegForm'export default class App extends React.Component{  render(){    return(<View style={Styles.Container}><RegForm /></View>    )  }}const styles=StyleSheet.Create({  container:{    flex:1 ,    justifyContent:'center',    backgroundColor:'#36485f' ,    paddingLeft:60 ,    paddingRight:60 ,  },})
This is the code for the registration page of the app
***RegForm***import React from 'react'import{StyleSheet,Text,View,TextInput,TouchableOpacity}from 'react-native'export default class RegForm extends React.Component{  render(){    return(<View style={Styles.RegForm}><Text style={styles.header}>Registration</Text><TextInput style={styles.TextInput} placeholder="Please Enter your Name" /><TextInput style={styles.TextInput} placeholder="Please Enter your Email" /><TextInput style={styles.TextInput} placeholder="Please Enter your Password"        secureTextEntry={true} /><TextInput style={styles.TextInput} placeholder="Please Enter your Mobile No" /><TextInput style={styles.TextInput} placeholder="Please Enter your CNIC" /><TouchableOpacity style={styles.button}><Text style={styles.btntext}>Sign Up</Text></TouchableOpacity></View>    )  }}const styles=StyleSheet.Create({  RegForm:{    alignSelf:'strech' ,  },  header:{fontSize:24 ,color:'#fff',paddingBottom:10 ,marginBottom:40 ,borderBottomColor:'#199187',borderBottomWidth:'1',  },  TextInput:{      alignSelf:'strech',      height:40 ,      marginBottom:30 ,      color:'#fff' ,      borderBottomColor:'#f8f8f8',      borderBottomWidth:1 ,  },  button:{      alignSelf:'strech',      alignItem:'center',      padding:20 ,      backgroundColor:'#59cbbd',      marginTop:30 ,  },  btntext:{      color:'#fff',      fontWeight:'bold',  }})

react-native how multiple scrollview can be synchronized

$
0
0

react-native synchronous movement of 5 of scrollView .how do you ı sync.

<ScrollView horizontal ref={scrolListRef}                        onScrollEndDrag={(e) =>                            //ref get xcoordvalue//scrollListRef map into ref xcoord asssigment                         }                        pagingEnabled                        scrollEventThrottle={16}>

onScroll : leads to an endless loop onScrollEndDrag:it creates a delay problem


react native - collapse table

$
0
0

I plan to make a collapse table. You can find it in this link

I tried:

  • Using a Custom Component for column name and FlatList for the first column
  • Using Section list for the rest column

=============================================================
| _____Custom Component_____ | __________Section list header__________ |
|============================================================|
| _________Flat List___________| __________ Section list body____________|
|============================================================|

I am able to make the list scroll together. However, if the list has 450+ rows, the performance will be reduced dramatically.

Please let me know if you have any solution.

Thank you in advanced!

Passing data from a React Native App to iOS and Android

$
0
0

I quite finish to build my app and I'm using an external solution to get push notifications and analytics (in the native code).

I have to send them the email of the user when logged to "allow" notifications. I tried it in a static way, and it works like a charm.

Android exemple :

HashMap contactData = new HashMap();contactData.put("f_EMail", "email@gmail.com");

But now, I need to find a way to send the email stored in React Native App to iOS Xcode and Android Studio. In a more dynamic way

I read the documentation about the bridge between react native and native but I didn't understand everything. I read some topics here but no one seems to have found the solution.

Did someone can help me ?

Thank you

How to store object in iOS (Objective-C) and Android (Java) in a React Native App

$
0
0

I'm developing an app in React Native. I have to do something in native side (Objective-C for iOS and Java for Android).

I get after log in an object :

{"success":"true", "action":"logged", "email":"email@gmail.com", "password":"1234567:wZ", "id":"1"}

I want to store that object on native side and use the email to initiate some native module but I don't know how to do it.I can do it easily on React Native tho.

So what I would like to do is :

  1. Save the object
  2. Get the email of the object
  3. Use the email in something like this : [customFieldsDictionary setObject:@"email" forKey:@"f_EMail"];

Anyone can help me please ? This is totally new for me.Thank you very much!

Expo: Does App Store also required to have property key when asking notifications permissions in able approve?

$
0
0

My app got rejected when I submit my app. This is my first time to upload an IOS app to app store. I saw a lot of having a same issue like happened to me. My app are requesting some permissions to the user without clarifying the purpose.

So as they told I have to add this to my info.plist.

"infoPlist": {"NSLocationAlwaysAndWhenInUseUsageDescription": "","NSLocationWhenInUseUsageDescription": ","NSLocationUsageDescription": "","NSCameraUsageDescription": "","NSPhotoLibraryUsageDescription" :""      }

But I also have an asking permission for push notification function. And I can't find if this is also required to have some steps in able to approve or no.

export async function askForNotificationsPermission() {  const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);  let finalStatus = existingStatus;  // only ask if permissions have not already been determined, because  // iOS won't necessarily prompt the user a second time.  if (existingStatus !== "granted") {    // Android remote notification permissions are granted during the app    // install, so this will only ask on iOS    const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);    finalStatus = status;  }  // Stop here if the user did not grant permissions  if (finalStatus !== "granted") {    return null;  }  // Get the token that uniquely identifies this device  let token = await Notifications.getExpoPushTokenAsync();  return token;}

Is it possible to make two mobile projects within single build?

$
0
0

I am newly join react technology, I created a small expo project but now it wants to introduce react-native, So I wil have parent (Expo Project) and child (React-Native with some differents module). How can i combine those project into one.

Is there any possibility please guide on it.

Thanks in advance

where to find ipa file after npx react-native run-ios --configuration Release and successfully running on Simulator

$
0
0

I followed the instructions on this link about Building your app for production:http://reactnative.dev/docs/running-on-device

AFter running the following commands:

npx react-native run-ios --configuration Release

It Built successfully and now it is running on the Simulator

However I don't know where to find the ipa file. Where can I find and get the ipa file after running the above command???

Using React Native Native Modules in Objective-C

$
0
0

I want to use a Native Module to get a data from React Native to Objective-C.I followed the demo from the documentation :

RCT_EXPORT_MODULE();RCT_EXPORT_METHOD(getEmail:(NSString *)email){  RCTLogInfo(@"Getting %@", email);}

I have my email into the RCTLogInfo but that's not what I want. And I'm a total newbie with Objective-C.

I would like to :

  1. Save my email into a variable or something I could use and not just having it in a log...
  2. I want to call it into AppDelegate to declare it to a module.

Example :[customFieldsDictionary setObject:email forKey:@"EMail"];

If someone sees this, it would saving my day!

Thank you!


React Native with ScrollView feels sluggish

$
0
0

Any idea why ScrollView + multiline TextInput + KeyboardAvoidingView feels really sluggish? I'm using react-navigation with the react-native-screen for the native modal look. The screenshot gif below is taken on emulator but it behave similarly even on the real device (notice that there is a flash of blue background just before keyboard showed up)

My code looks something like (I set the KeyboardAvoidingView background to pink so it's easy to spot and ScrollView background is set to blue

<KeyboardAvoidingView behavior={'padding'} style={{flex: 1, backgroundColor: 'pink'}} keyboardVerticalOffset={48}><View style={{flex: 1}}><View style={styles.header}><Text>{date}</Text><Button title="Delete"/><Button title="Save"/></View><ScrollView keyboardDismissMode={'interactive'} style={{flex:1, backgroundColor: 'blue'}}><TextInput onChangeText={(text) => setNote(text)}                       placeholder='Note'                       value={note}                       multiline={true}                       scrollEnabled={false}                       style={{flex: 1, backgroundColor: '#fff'}}            /></ScrollView></View></KeyboardAvoidingView>

I'm also using react-native-elements, react-navigation+react-native-screens for the native modal look

screenshot

PS - I tried not using ScrollView and simply using TextInput with scrollable={true} which seems to be working but the problem with that is I can't dismiss the keyboard once the keyboard is shown

Apple Signin returns 'invalid_grant' on web but app doesn't

$
0
0

I'm applying Apple Signin on both app and web. But Apple server always returns error invalid_grant if I signin in web and verifying it.

The following is simple environment for my service.

The app is made by ReactNative and the server is nodejs.

The Certificate values are, for example, following.

TeamID : 9BF12AAppID : com.fooServiceID : com.foo.web (its bound primary key(?) is AppID com.foo)KeyID : 12ABC4 (its bound primary key(?) is AppID com.foo)...

And when signin in the app, it sends authorizationCode and identityToken to the server url /auth/apple.

When signin in the web, it open the Apple signin page. And when complete the signin process, the Apple returns the code and id_token to the server url /auth/apple (referencing here).

So, in my server route /auth/apple, I receive code(authorizationCode) and id_token(identityToken) from the app and web.

And to verify the id_token, I make client_secret and verify the code using following functions

// isrn : if the values(code and id_token) are come from the app(react native)const get_client_secret = isrn => {  // sign with RSA SHA256  const privateKey = get_private_key(); // pseudo  const token = jwt.sign({}, privateKey, {    algorithm: 'ES256',    expiresIn: '10h',    audience: 'https://appleid.apple.com',    issuer: 9BF12A, // TeamID    subject: isrn ? com.foo : com.foo.web, // if the code from react native app, use AppID, else use ServiceID    keyid: 12ABC4,  });  return token;};const verify = (code, isrn) => {  let b;  let e;  return new Promise(resolve => {    axios.post('https://appleid.apple.com/auth/token',      querystring.stringify({        grant_type: 'authorization_code',        code,        client_secret: get_client_secret(isrn),        client_id: isrn ? com.foo : com.foo.web,        redirect_uri: 'https://testurl.com/auth/apple',      }),      {        headers: {'Content-Type': 'application/x-www-form-urlencoded',        },      })    .then(r => {      b = r.data;    })    .catch(err => {      e = err.response ? err.response.data : { err };    })    .finally(() => {      resolve({ b, e });    });  }).catch(err => {    resolve({ b, e: err });  });};

And I just use it in route /auth/apple like

app.post('/auth/apple', (req, res, _) => {  const { body: { isrn, code, id_token } } = req;  verify(code, isrn).then(({ b, e }) => {    // if code came from the app, b has result values like access_token and e is undefined    // but if code came from the web, b is undefined and e has value 'invalid_grant'    log('******* verify : ', b, e);    // some process  });});

When the code and id_token come from web, the error is returned with invalid_grant but in case of app, the return value is fine.

How can I verify the code which come from the web like the app does?

Or, I couldn't ?

Could not connect to development server - React Native

$
0
0

I am creating an app using react native. I tried to change a file path to an image within my code and when I ran my app on the iOS emulator the following message was displayed.

error

I have tried a number of different methods such as closing the terminal and running the app again.

I also tried running localhost:8081 in my browser and was given the following message

erorro2

I have also tried deleting my node_modules folder and running yarn but this still hasn't fixed the problem.

Any ideas as to how I would fix this?

react-native-youtube no video sound when phone is in silent mode

$
0
0

I know there are similar questions, but every solution I've tried has failed, unfortunately. I'm using react-native-youtube and the sound of the videos is not playing on iOS when the phone is in silent mode.

I tried importing <AVFoundation/AVFoundation.h> in the beginning of AppDelegate.m and added this line

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: nil];

at the bottom of didFinishLaunchingWithOptions as described in their README.

I also tried enabling Audio on the Background Modes in Xcode and added audio in the Background modes in the Info.plist file.

React Native 0.44.3react-native-youtube 1.1.0iOS 11.2.2

onShouldStartLoadWithRequest automatically calling in iOS React Native on loading of any url in WebView, How to control it?

$
0
0

I'm implementing in App WebView for my App. I've to open some info pages and I've to get some data based on the click of any particular place(which contains a different type of data) in webview. But in iOS, while loading any URL onShouldStartLoadWithRequest calling automatically which leads opening different URLs in the HTML content. But it is working as expected in Android.

<WebView  originWhitelist={["*"]}  style={style}  source={source}  showsVerticalScrollIndicator={showsVerticalScrollIndicator}  startInLoadingState={startInLoadingState}  javaScriptEnabled={true}  onShouldStartLoadWithRequest={request => {    return onLoadWebViewOnClick(request)  }}/>

in this handleUrlNavigation will handle the request of any click action, but it is automatically calling every time. How can I handle this?

Viewing all 16564 articles
Browse latest View live