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

How to implement RTL in iOS using EXPO/react-native

$
0
0

I have added two localization file (arabic and english) in my react native application file names like ar.json and en.json.

My en.json file looks like

"fieldNames": {"enterEmail" : "Enter the email address"  },

My ar.json file looks like

"fieldNames": {"enterEmail" : "أدخلعنوانالبريدالإلكتروني"  },

My string/index.js file looks like below:

import * as Localization from 'expo-localization';import i18n from 'i18n-js';import en from './en.json';import ar from './ar.json';i18n.fallbacks = true;i18n.translations = { en, ar };i18n.locale = Localization.locale;export const string = value => i18n.t(value);export default i18n;

One of the file I used like the following

<Text>{string('fieldNames.enterEmail')}</Text>

Localization is working fine with both languages.

But when I choose arabic its not aligned to right side in iOS.

In my android device its working properly.This issue appear only in iOS .

Could you please help me to resolve the issue


Cannot set true value for I18nManager.allowRTL

$
0
0

I would like to enable RTL on my iOS project using EXPO.

Then I tried to enable like

I18nManager.allowRTL(true); 

It cannot be set to true.I checked the value by using the following code

console.log('Value is: '+I18nManager.isRTL);//This always retuns FALSE

Please help me how to solve this issue

Is there a way to detect whether the app was opened via push notification? (React-native)

$
0
0

I am building react-native application using OneSignal library. When the app is opened via push notification, I want to make some additional steps before all of the app's logic: I don't want to render initial screen, I want to delay hiding splash screen, etc. That is why I need to detect whether the app was opened via push notification or not. So I could behave in a different ways. Push notification libraries provide callbacks that fire when notifications are opened, but there is no way to detect when they are called: by that time my initial screen can be already rendered, splash screen can be already hidden, etc.

I'm building both iOS and Android apps. I've found a similar question, but it covers only iOS case.

Navigator & AsyncStorage react native

$
0
0

Hello i'm new in react native and currently learn about AsyncStorage.

I want to implement conditional to render navigator. If there's value key in AsyncStorage, the initial route go to Page2 and if there's no value key in AsyncStorage, the initial route go to Page1.

If i close the app and re-open again, I want it shows me the corresponding page whether there is a key. please help.

Here's what i've done so far:

import React, { Component } from 'react';import {  AppRegistry,  TextInput,  StyleSheet,  Text,  View,  Navigator,  TouchableOpacity,  AsyncStorage,} from 'react-native'; var initialRoute = {id: 1}var STORAGE_KEY = '@AsyncStorageExample:key';var SCREEN_WIDTH = require('Dimensions').get('window').width;var BaseConfig = Navigator.SceneConfigs.FloatFromRight;var CustomLeftToRightGesture = Object.assign({}, BaseConfig.gestures.pop, {  snapVelocity: 8,  edgeHitWidth: SCREEN_WIDTH,});var CustomSceneConfig = Object.assign({}, BaseConfig, {  springTension: 100,  springFriction: 1,  gestures: {    pop: CustomLeftToRightGesture,  }});var Page1 = React.createClass({  _goToPage2() {    AsyncStorage.setItem(STORAGE_KEY, "this is the key");    this.props.navigator.push({id: 2})  },  render() {    return (<View style={[styles.container, {backgroundColor: 'white'}]}><Text style={styles.welcome}>          This is Page 1</Text><TouchableOpacity onPress={this._goToPage2}><View style={{paddingVertical: 2, paddingHorizontal: 7, backgroundColor: 'black'}}><Text style={styles.buttonText}>Save Key</Text></View></TouchableOpacity></View>    )  },});var Page2 = React.createClass({  componentDidMount() {    this._loadInitialState();  },  async _loadInitialState() {    try {      var value = await AsyncStorage.getItem(STORAGE_KEY);      if (value !== null){        this.setState({selectedValue: value})      } else {      }    } catch (error) {    }  },   getInitialState() {    return {      selectedValue: null    };  },  _signOutPressed(){    AsyncStorage.removeItem(STORAGE_KEY);    this.props.navigator.push({id: 1})  },  render() {    if(this.state.selectedValue === null) {      begin = <Page1 />    } else{      begin = <View style={[styles.container, {backgroundColor: 'white'}]}><Text style={styles.welcome}>This is Page 2</Text><Text>KEY: {this.state.selectedValue}</Text><TouchableOpacity onPress={this._signOutPressed}><View style={{paddingVertical: 2, paddingHorizontal: 7, margin: 10, backgroundColor: 'black'}}><Text style={styles.buttonText}>Delete Key</Text></View></TouchableOpacity></View>    }     return (      begin    );  },});var TestAsync = React.createClass({  _renderScene(route, navigator) {    if (route.id === 1) {      return <Page1 navigator={navigator} />    } else if (route.id === 2) {      return <Page2 navigator={navigator} />    }  },  _renderScene1(route, navigator) {    if (route.id === 1) {      return <Page1 navigator={navigator} />    } else if (route.id === 2) {      return <Page2 navigator={navigator} />    }  },  _configureScene(route) {    return CustomSceneConfig;  },  render() {      var initialRoute = {id:1}      if(AsyncStorage.getItem(STORAGE_KEY) != null){        initialRoute = {id:2}      }      return(<Navigator          initialRoute={initialRoute}          renderScene={this._renderScene}          configureScene={this._configureScene} />      );    }});const styles = StyleSheet.create({  container: {    flex: 1,    justifyContent: 'center',    alignItems: 'center',    backgroundColor: '#F5FCFF',  },  welcome: {    fontSize: 20,    textAlign: 'center',    margin: 10,    color: 'black',  },  buttonText: {    fontSize: 14,    textAlign: 'center',    margin: 10,    color: 'white',  },  default: {    height: 26,    borderWidth: 0.5,    fontSize: 13,    padding: 4,    marginHorizontal:30,    marginBottom:10,  },});module.exports = TestAsync;

How to get current route name in react-navigation?

$
0
0

I want the name of the current route or screen in react-navigation which I want to use inside if condition to make some changes.

3D Animations on View with React Native

$
0
0

I want to implement a flip effect in my React Native app, similar like described here:

https://www.codementor.io/reactjs/tutorial/building-a-flipper-using-react-js-and-less-css

My question is. Can I achieve it somehow with the help of some library like 'Animations'https://facebook.github.io/react-native/docs/animations.html or I have to play with 'plain' CSS styles.

What is the 'good practive' for such animations in React Native?

class CardBack extends Component {  render() {    return (<TouchableOpacity onPress={this.flip}><View style={styles.scrumCardBorder}><View style={styles.cardBack}></View></View></TouchableOpacity>    );  }  flip() {    this.setState({flipped: !this.state.flipped})  }}class CardFront extends Component {  render() {    return (<TouchableOpacity><View style={styles.scrumCardBorder}><View style={styles.cardFront}><Text style={styles.cardValue}>5</Text></View></View></TouchableOpacity>    );  }}

Having a react native ios issue "apple match 0 linker error"

$
0
0

I am generating a react native ios app using xcode but i am experiencing an issue "apple match 0 linker error". i have tried a lot of stuff to resolve this but i am getting any solution that work perfectly fine here is the screen shot attached please have a look on it.

enter image description here

How do I send data from server to an app?

$
0
0

I want to send some data:Database ==> server ==> app

I don't know what type of communication to use.Restful api ? Tcp ? or just get request ?App will get the data and display it in form of individual posts.


How to create view A closed then view B needs to show using react native?

$
0
0

In my scenario, I am creating single page two views. View A and View B, Here, I am maintaining two views A and B in a function call with separate render. View A having close button once its clickable enabled then View A needs to hide and View B needs to render. How to achieve this?

Main RenderRenderMain() {      return (<View>………….</View>        {this.renderViewA()} // Here rendering view A on main view)}View A Function renderViewA() {      return (<Overlay>…………. // Here rendering View A close click to hide View A and show View B</Overlay>)}View B FunctionrenderViewB() {      return (<Overlay>………….</Overlay>)}

Function generating data according to state value not changing after first render

$
0
0

I am creating a Login and Register screen and I want the use to have an option to choose to register with email or phone number.

I am using a radio button for this, and for some reason the function does not change its render when I change the state(the state is for sure changed, I checked it with console.log).

Code:

export default class App extends React.Component {    constructor(props) {        super(props);        this.state = {            //login            email: "",            password: "",            //register            firstName: "",            lastName: "",            date: new Date(),            checked: "Use Email Address",            ...        }    }    componentDidMount() {        ...        Register = Register.bind(this);        RadioButton = RadioButton.bind(this);    }    onRadioChange(label) {        if (label === "Use Email Address") {            this.setState({ checked: "Use Email Address"})            console.log('test2')        } else {            this.setState({ checked: "Use Phone Number" })            console.log('test')            console.log(this.state.checked)        }    }    render() {        return (<Stack.Navigator initialRouteName="Login"><Stack.Screen name="Login" component={Login} options={{ headerShown: false }} /><Stack.Screen name="Register" component={Register} options={{ headerShown: false }} /></Stack.Navigator>        )    }}function RadioButton(label) {    return (<View style={{ flexDirection: 'row', alignItems: 'center', marginTop: 5, marginBottom: 5 }}><TouchableOpacity                onPress={() => { this.onRadioChange(label) }}                style={{                    height: 24,                    width: 24,                    borderRadius: 12,                    borderWidth: 2,                    borderColor: '#FF9C09',                    alignItems: 'center',                    justifyContent: 'center',                }}>                {                    this.state.checked === label ?<View style={{                            height: 10,                            width: 10,                            borderRadius: 5,                            backgroundColor: '#FF9C09',                        }} />                        : null                }</TouchableOpacity><Text style={{ marginLeft: 10, fontFamily: 'open-sans-regular' }}>{label}</Text></View>    );}function Register({navigation}) {    ...    return(     ...    {RadioButton("Use Email Address")}    {RadioButton("Use Phone Number")}    ...   )}

I guess this has something to do with the lifecycles? I mean I am updating the state and I binded this with function RadioButton.

Note: When it's first loaded it shows "Use Email Address" as checked correctly. It just does not change when I check "Use Phone Number".

Any help would be very much appreciated.

React-Native app built using Expo is working fine on simulator on device (iOS) threw Expo, but crashes when running using TestFlight

$
0
0

In the logs, I see this error:

failed to get process exit details for UIKitApplication:com.abc.www[8bae][rb-legacy] : Could not find specified service (113)

Working fine when running using Expo (on both simulator and device)Crashes on Testflight with the above error...

Has anyone came across this kind of issue?

dyld: Library not loaded: React native

$
0
0

I have developed the “SampleApp iOS framework” with swift development and using the below dependencies in our app:

pod 'Alamofire', '4.9.1'pod 'JGProgressHUD', '2.0.3'pod 'FirebaseCore', '6.4.0'pod 'FirebaseMessaging', '4.1.10'

We can able to integrate the my “SampleApp framework” in the native swift application and it’s working file. But while integrated and run the same framework in the react native project. I am getting the below error

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire  Referenced from: /private/var/containers/Bundle/Application/F50D-C62F291D4-8E6B-07B23BA0D-C6-B2E9-91AE/MyFirstApp.app/Frameworks/SampleApp.framework/SampleApp  Reason: image not found

Steps to be followed for integrating SDK in reaction native is below:

1.Installed and run the node

2.sudo chown -R $USER /usr/local/lib/node_modules

3.react-native init MyFirstApp

  1. iOS and android folders are generated.

5.I have opened the sample app framework and added my dependencies in pod install then run the pod install command.

6.Run the app in the Xcode Run option. App gets opened and getting the above alamo fire error

target 'FirstApp' do  # Pods for FirstApp  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'pod 'Alamofire', '4.9.1'pod 'JGProgressHUD', '2.0.3'pod 'FirebaseCore', '6.4.0'pod 'FirebaseMessaging', '4.1.10'

Note: I have not used the Visual studio, I just open the iOS folder and do all changes same as native app. Is any other things needs to be added for react native project?
I just wanted to compile the sample app without error.

method is not a recognised objective c method

$
0
0

Lot of question are asked regarding the same but none of them solve my error.

Here is my objective c file

#import <Foundation/Foundation.h>#import <React/RCTBridgeModule.h>#import <UIKit/UIKit.h>@interface RCT_EXTERN_MODULE(LanguageTranslationModule, NSObject)RCT_EXTERN_METHOD(callbackMethod:(NSString*)englishText (RCTResponseSenderBlock)callback)@end

Here is my swift class

@objc(LanguageTranslationModule)class LanguageTranslationModule: NSObject {  var resultCallback: RCTResponseSenderBlock!  @objc func callbackMethod(_ englishText: String, callback: @escaping RCTResponseSenderBlock) -> Void {    resultCallback = callback    debugPrint("Hi there")    translateText(msg: englishText)  }...

Here is my JS call from React Native

LanguageTranslationModule.callbackMethod(englishText, (err, r) => {        if (!err) {          setProgress(false);          setMarathiText(r.text.toString());        } else {          setProgress(false);          setMarathiText(err);        }      });

have added underscore to my first parameter in swift file as that is most of the solution to other questions asked on stack as well as there is space between the underscore and actual variable name. If I remove the englishText variable from all the files and hardcode that text in swift file then my function works fine. of course then I had to add underscore to the callback variable, so no logical error from my side

setTimeout in React Native

$
0
0

I'm trying to load a splash screen for an iOS app built in React Native. I'm trying to accomplish this through class states and then a setTimeout function as follows:

class CowtanApp extends Component {  constructor(props){    super(props);    this.state = {      timePassed: false    };  }  render() {    setTimeout(function(){this.setState({timePassed: true})}, 1000);    if (!this.state.timePassed){      return <LoadingPage/>;    }else{      return (<NavigatorIOS          style = {styles.container}          initialRoute = {{            component: LoginPage,            title: 'Sign In',          }}/>      );    }  }}

The loading page works for a second, and then I guess when setTimeout tries to change the state to true, my program crashes: 'undefined is not an object (evaluating this.setState)'. I've been going at this for a couple of hours, any ideas on how to fix it?

How to make React Native Animated.View clickable?

$
0
0

I'm using this react native tinder demo ->https://github.com/brentvatne/react-native-animated-demo-tinder

Is it possible to make the cards 'clickable' so it would navigate to another view on click? I've tried wrapping the "Touchable" components around the animated view but doing so disables the animations.

Any ideas would be highly appreciated, thanks!


TUICandidateView:unrecognized selector sent to instance

$
0
0

My project is a react-native project.

Crash information as below:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TUICandidateView collectionView:didSelectItemAtIndexPath:]: unrecognized selector sent to instance 0x1056236f0'*** First throw call stack:(0x1975f3ab0 0x19730d028 0x1974f1f10 0x19b708a80 0x1975f8254 0x1975fa3f0 0x19af06fbc 0x19af2f288 0x19b70728c 0x19b707388 0x19b70728c 0x19b707388 0x19b7159c0 0x19b716cb0 0x19b6f26d8 0x19b76cd2c 0x19b76f2e4 0x19b768468 0x19756f24c 0x19756f1a0 0x19756e90c 0x1975697d8 0x197569084 0x1a17b7534 0x19b6d9698 0x102f2b0dc 0x1973e8e18)libc++abi.dylib: terminating with uncaught exception of type NSException

react-native version: 0.55.4

Xcode version: 11.3

iOS version: 13

  1. I tried on the simulator and my iPhone devices. both are crashed.

  2. I have searched for much-related information about TUICandidateView on google, but it gives me nothing.

If you have any information about it. please let me know.

Thanks in advance


Finally, I solved it.

The reason why my app crashed is I add some other sensitive SDK to my project. and It will monitor my code and raise an exception. So I remove the SDK and no more crash.

library not found for -lAppAuth

$
0
0

I try build IPA file on Xcode from .xcodeproj file and I obtain next error log:

library not found for -lAppAuth

And I never installed that package.

After that, I've decided to install this package, but error continues

Steps:

  • Generic iOS device
  • Product>Archive

error log

Enviroment

  • React v16.9.0
  • React Native v0.61.2
  • MacOS Movaje 10.14.3
  • Xcode 10.3 (not update because i can't update OS)

What is the best way to develop a video, voice call app in react-native [closed]

$
0
0

I want to create a voice, video call app in react-native, but actually I dont know where to start from?I found react-native-webrtc package to buggy and also the maintainer is to busy and cant help us, therefor I decided to develop my own, but now I need to know where to start from and how can I bring webrtc support to my react-native app, to support both android and ios.

Please help me in way of creating my own and not using react-native-webrtc, because I already was using it, but is not responding as well and have a lot of bugs. and also it is hard to me to edit and existed code..

export the switch value of a class in react native

$
0
0

I am new to React Native and I'm sorry for my english if i make mistakes!

I'm trying to create a smartphone app with reactnative and nativebase.

I have one page for the settings with a switch and I have a function called Base in one other js file, with the layout for multiple cooking recipes, but my problem is:

I would like that by activating the switch, my measurements in ml become in ozbut I can't even import the state of the switch ...

how can I import the status of the switch?

Thank you!

Settings.js

class Settings extends Component {constructor(props) {    super(props);state = {     switchValue: false}toggleSwitch = (value) => {    this.setState({ switchValue: value })}render() {    return (<Container style={styles.container}><Header><Left><Button                        transparent                        onPress={() => this.props.navigation.openDrawer()}><Icon name="menu" /></Button></Left><Body><Title>Settings</Title></Body><Right /></Header><Content><List><ListItem><Left><Text>Impostare le misurazioni come ml</Text></Left><Right><Switch                        style={{ marginTop: 30 }}                        onValueChange={this.toggleSwitch}                        value={this.state.switchValue}/></Right></ListItem></List></Content></Container>    );}}export default Settings;

Base.js

 export function Base(props) {  return (<Container style={styles.container}><Header style={{backgroundColor:props.headercolor}}><Left><Button transparent><Icon name="arrow-back" /></Button></Left><Body style={{ flex: 1.2 }}><Title>{props.title}</Title></Body><Right><Text>e</Text></Right></Header><Grid><Row size={25}><Image        style={{ flex: 1, height: null, resizeMode: 'contain', width: null}}        source={path_pageimage[props.title]}      /></Row><Row size={75}><Col size={35}><Row size={5}><Body><Title style={styles.title}>Preparations</Title></Body></Row><Row size={15} style={{ borderBottomColor: "gainsboro", borderBottomWidth: 1 }}><Col size={35}><View style={{ flex: 1, flexDirection: 'column', justifyContent: 'center' }}><Text>Glass:</Text></View></Col><Col size={65}><View style={{ flex: 1, flexDirection: 'column', justifyContent: 'center' }}><View style={{ height: "80%" }}><Image                  style={{ flex: 1, height: null, resizeMode: 'contain', width: null }}                  source={path_glass[props.glass]}                /></View><View style={{ alignItems: "center" }}><Text style={{ fontSize: 12 }}>{props.glass}</Text></View></View></Col></Row><Row size={7}><Body><Text style={{ fontWeight: "bold" }}>{props.preparation}</Text></Body></Row><Row size={73}><Image            style={{ marginTop: 0, flex: 1, height: null, resizeMode: 'contain', width: null }}            source={path_preparation[props.preparation]}          /></Row></Col><Col size={65} style={{ borderLeftColor: "gainsboro", borderLeftWidth: 1 }}><Row size={5}><Body><Title style={styles.title}>Ingredients</Title></Body></Row><Row size={55} style={{ marginBottom: 5, borderBottomColor: "gainsboro", borderBottomWidth: 1 }}><FlatList            style={{ marginLeft: 10 }}            horizontal={false}            numColumns={2}            data={props.utlizatedingr}            keyExtractor={(item, index) => index.toString()}            renderItem={({ item }) => (<TouchableOpacity                onPress={() => this.props.navigation.navigate(item.l)}><View><Liquor l={item.l} q={item.q}/></View></TouchableOpacity>            )}          /></Row><Row size={5}><Body><Title style={styles.title}>Curiosity</Title></Body></Row><Row size={35} style={{ marginLeft: 20 }}><ScrollView> <Text>{props.curiosity}</Text></ScrollView></Row></Col></Row></Grid></Container>  );}function Liquor(props) { //.l = liquor, .q = quantity   return (<View style={{ flex: 1, flexDirection: 'row' }}><View style={{ width: "25%", margin: 5 }}><Image source={path_ingredients[props.l]} style={{ height: 80, width: 40 }} /></View><View style={{ marginLeft: 10, marginTop: 5, justifyContent: "space-evenly" }}><Text style={{ fontWeight: "bold" }}>{props.l}</Text><Text>{props.q} oz</Text></View></View>  );    }

Example Recipes: Mojito.js

import { Base } from "../constructor_recipes/base"const title = "Mojito"const headercolor = "green"const buttoncolor = "blue"const utlizatedingr = [{  l: "Rum",  q: "4"},{  l: "Vodka",  q: "2" }, {  l: "Vodka",  q: "5"}] const glass = "Double Rock" const preparation = "Shake & Pour" const curiosity = "Lorem ipsum dolor sit" class Mojito extends Component {   render() {return (<Base    title={title}    headercolor = {headercolor}    buttoncolor = {buttoncolor}    utlizatedingr={utlizatedingr}    glass={glass}    preparation={preparation}    curiosity={curiosity}></Base>   );  } }  export default Mojito;

Xcode debug build vs release build

$
0
0

I am currently building a react native app using expo.

However, I needed to use cocoapods, which is why I am now using Xcode.

Since I have switched to Xcode, there has been a difference between my local debugging builds (that I run to a USB connected iPhone) vs the builds that get pushed to TestFlight.

After doing some digging I have found that it may be due to the debug vs release schemes in Xcode.

From what I've see it seems that the difference should really just be in performance, file sizes, and some other aspects, but not what the app actually does and displays like in my case.

To test, I made a change on my app's homepage to simply have the text, UPDATED.

As expected, when ran with the debug scheme, the UPDATED text shows up, but when ran with the release scheme, it does not.

How do I get these to sync up and have the release build recognize the changes I make as I am certain I do not want to push a debug build to the app store?

Things I have tried:

  • Removing/cleaning Build folder and rebuilding
  • Updating Xcode
  • Running on another device
  • Building/running with expo (this did something, but it just causes the app to crash, assuming it is because of the cocoapods)

Versions:

  • react-native: 0.61.5
  • Xcode: 11.4.1
  • macOS: 10.15.3

Thank you

Viewing all 16541 articles
Browse latest View live


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