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

How to handle a change in system level font size on iOS with React Native?

$
0
0

We have a situation where if a user decides to increase the "Larger Text" size in iOS Settings (see image below), it then messes up our view layouts in React Native, as the font size will now be larger.

For example here is a ListView row BEFORE changing the "Larger Text" setting in iOS system settings:

enter image description here

And here is the same row AFTER increasing the "Larger Text" setting:

enter image description here

What is best practice to handle such font scale increase in React Native ? This is obviously just one example, and there are other scenario's such as a View that only contains Text, but we do not want to increase the height of that View at runtime.

Appreciate anyone's advice on this, thanks!

enter image description here


How to set app orientation based on device without ejecting from Expo?

$
0
0

I'd like to lock my app to portrait mode on iPhone and enable both portrait and landscape on iPad.

I know you can easily do this by updating info.plist on Xcode, but is it possible to set these preferences without ejecting from Expo? After ejecting, I got hundreds of errors on Xcode and my builds keep failing so I'd prefer to keep things as is if possible.

Here are the relevant parts of my app.json file.

{
  "expo": {
    "sdkVersion": "35.0.0",
    "platforms": ["ios"],
    "version": "1.0.0",
    "orientation": "default",
    "ios": {
      "bundleIdentifier": "BUNDLE-IDENTIFIER",
      "supportsTablet": true
    }
  }
}

React native webview vs swift/java webview

$
0
0

I am trying to work with developers who have given me answers I an not really sure of. And I lack any experience to judge the answers.

Is the look and feel of react native webview much different from look and feel of swift/java webview ?

Also is the performance different between the two also?

I did find a similar post on github but it was not answered.

How to exhaustively list up the subscriptions made by AWS appsync graphql operation in React Native

$
0
0

I am currently building a real-time messaging iOS application using React-Native and AWS-Appsync-GraphQL.

The basic architecture is when a user creates message on DynamoDB, the subscription triggers event function that renders the message to another users chat room.

The app has mutliple chat rooms and user shall reside in only one of them. Subscription is created when user enters the chat room and it become unsubscribed when the user leaves the room. And then new subscription is created then subscribed.

(Note that all subscriptions are specific to each chat room since I am using filtering argument for subscription.)

The most important feature to develop the app is how to manage the subscriptions. I need to keep subscribing/unsubscribing the subscriptions while prevents multiple subscriptions occurs. (I had observed that the app crashes when unsubscribed subscription stacked.)

Currently I had made a list and put the subscribed object into the list and unsubscribes it when user leaves the chat room then empty the list. Then put another subscribed object into it. This process happens in sequence by leveraging ("async", "then") method in javascript.

The problem is I don't know why but sometimes the unsubscribed subscriptions occurs/stacks and makes error in the app, such as multiple message rendering.

So I want to exhaustively list up the socket connection that made by AWS appsync graphql subscription operation and then unsubscribe those all so that I could 100% guarantee there's no redundant subscrption. (I am unsubscribing and not making any more subscription when app goes to the background)

How could I list up the every socket connection generated in the app?

I couldn't find any documentation about this since all the google search results are tagerted into the In-app-purchase related subscrptions.

React native FCM iOS push notification not delivered .How to debug

$
0
0

first of all environment is React native, I try to setup push notification in iOS following instruction from rnfirebase package here what step i do

  1. create key

enter image description here

  1. then add to firebase

enter image description here

  1. add Google-service.plist and add setup following from firebase doc

enter image description here

and acivate capabillity enter image description here

  1. then I install pod package

enter image description here

  1. run app got token

enter image description here

  1. use token send on cloud messaging console

notification not delivered I didn't know what wrong because message also send from FCM and what happens on APNS where I get an error just confused

thank for advance

and also try by connecting directly with pusher enter image description here

and also not received again

then try to use Onesignal with same certificate with Firebase is work even on the test message

iOS react-native CameraRoll loads too slowly.

$
0
0

With react-native, I implemented IOS CameraRoll that fetches 300 images from 'Camera Roll' Album on first and keep fetching 300 images whenever scroll reaches the end. Below is My code.

SalmonCameraRoll.js

import React from 'react'

import {
  View,
  Text,
  TouchableHighlight,
  Modal,
  StyleSheet,
  Button,
  CameraRoll,
  Image,
  Dimensions,
  ScrollView,
  FlatList,
} from 'react-native'

import Share from 'react-native-share';
import RNFetchBlob from 'react-native-fetch-blob';

let styles
const { width, height } = Dimensions.get('window')
const fetchAmount = 300;


class SalmonCameraRoll extends React.Component {
  static navigationOptions = {
    title: 'Salmon Camera Roll',
  }

  constructor(props) {
    super(props);
    this.state = {
      photos: [],
      // index: null,
      lastCursor: null,
      noMorePhotos: false,
      loadingMore: false,
      refreshing: false,
    };
    this.tryGetPhotos = this.tryGetPhotos.bind(this);
    this.getPhotos = this.getPhotos.bind(this);
    this.appendPhotos = this.appendPhotos.bind(this);
    this.renderImage = this.renderImage.bind(this);
    this.onEndReached = this.onEndReached.bind(this);
    this.getPhotos({first: fetchAmount, assetType: 'Photos'});
  }

  componentDidMount() {
    this.subs = [
      this.props.navigation.addListener('didFocus', () => {
        this.getPhotos({first: fetchAmount, assetType: 'Photos'});
      }),
    ];
  }

  componentWillUnmount() {
    this.subs.forEach(sub => sub.remove());
  }

  tryGetPhotos = (fetchParams) => {
    if (!this.state.loadingMore) {
      this.setState({ loadingMore: true }, () => { this.getPhotos(fetchParams)})
    }
  }

  getPhotos = (fetchParams) => {
    if (this.state.lastCursor) {
      fetchParams.after = this.state.lastCursor;
    }

    CameraRoll.getPhotos(fetchParams).then(
      r => this.appendPhotos(r)
    )
  }

  appendPhotos = (data) => {
    const photos = data.edges;
    const nextState = {
      loadingMore: false,
    };

    if (!data.page_info.has_next_page) {
      nextState.noMorePhotos = true;
    }

    if (photos.length > 0) {
      nextState.lastCursor = data.page_info.end_cursor;
      nextState.photos = this.state.photos.concat(photos);
      this.setState(nextState);
    }
  }

  onEndReached = () => {
    if (!this.state.noMorePhotos) {
      this.tryGetPhotos({first: fetchAmount, assetType: 'Photos'});
    }
  }

  renderImage = (photo, index) => {
    return (
      <TouchableHighlight
        style={{borderTopWidth: 1, borderRightWidth: 1, borderColor: 'white'}}
        key={index}
        underlayColor='transparent'
        onPress={() => {
            this.props.navigation.navigate('Camera', { backgroundImageUri: photo.node.image.uri })
          }
        } 
      >
        <Image
          style={{
            width: width/3,
            height: width/3
          }}
          representation={'thumbnail'}
          source={{uri: photo.node.image.uri}}
        />
      </TouchableHighlight>
    )
  }

  render() {
    return (
      <View style={styles.container}>
        <View style={styles.modalContainer}>
            <FlatList
              numColumns={3}
              data={this.state.photos}
              initialNumToRender={fetchAmount}
              onEndReachedThreshold={500}
              onEndReached={this.onEndReached}
              refreshing={this.state.refreshing}
              onRefresh={() => this.tryGetPhotos({first: fetchAmount, assetType: 'Photos'})}
              keyExtractor={(item, index) => index}
              renderItem={({ item, index }) => (
                this.renderImage(item, index)
              )}
            />
        </View>
      </View>
    )
  }
}

styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  modalContainer: {
    // paddingTop: 20,
    flex: 1,
  },
  scrollView: {
    flexWrap: 'wrap',
    flexDirection: 'row'
  },
  shareButton: {
    position: 'absolute',
    width,
    padding: 10,
    bottom: 0,
    left: 0
  }
})

export default SalmonCameraRoll


Problem is that in circumstance of a lot of images(about 10000 images) in 'Camera Roll' album, each image component was loaded so slowly that it was also loaded too slowly when scrolling accordingly.

In other famous apps like Facebook or Instagram, it loads all images quickly at once without fetching whenever scroll reaches end.

How can i make my Image component load fast? Or best of all(if possible), how can i make my CameraRoll load all images quickly at once without fetching whenever scroll reaches end?

Thank you.

Allow user to change app notification sound

$
0
0

I have an app that uses Firebase Messaging to send notifications, and I have a set of sounds added to my xcode project resources, to play on the device.

I send the notification to users subscribed to specific topics, from my server like this:

"apns": {
    "headers": {
        "apns-priority": "10",
    },
    "payload": {
        "aps": {
            "alert": {
                "title": titleMessage,
                "body": bodyMessage,
            },
            "sound": 'alert.wav',
        },
    },
}

Now the sound "alert.wav" plays fine on the device, when the notification is received.

What I want to do is inside my app: I want to allow users to change the notification sound, from different sets of sounds.

Example: Option to play sound from: set 1, or set 2. and I would have them in my app as seperate folders with the same file names.

Is this possible in iOS? and how can I achieve it in react native?

ld: library not found for -lDoubleConversion React Native 0.59

$
0
0

I have this error

❌  ld: library not found for -lDoubleConversion

❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)


error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening App.xcworkspace

** BUILD FAILED **

The following build commands failed:
    Ld /Users/mohamedelmi/workspace/elmi/food-frontend/ios/build/App/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App normal x86_64
(1 failure)

here is what i did

  1. I clean and rebuild still have the error
  2. rm -f ~/Library/Developer/Xcode/DerivedData/ModuleCach

React Native ios picker is always open

$
0
0

I have two pickers on my screen. Whenever I navigate to the screen in iOS app I find that the pickers are always open and all options are visible.

enter image description here

It works perfectly fine in Android where the options are visible only after we click on the picker.

Can somebody suggest a solution to fix this in iOS?

Integrating Password Manager Into iPhone App

$
0
0

I've noticed a few iPhone apps have started to allow you to use your password manager to sign in. Slack is an example of this:

Slack login

Slack password manager

It looks like there's a link that's triggering a partial version of the share toolbar in Safari which lets you access your favourite password manager's widget. That's all I've been able to figure out so far though.

My question is, how have they got this functionality into their app? I'm primarily developing things using React Native, but if it needs a custom component then that's not a problem.

Laxical or preprocessor error "GeneratedDotEnv.m" file not found

$
0
0

I have updated my React native from 0.57.7 to 0.59.10. When I compile through Xcode it shows me the error:

GeneratedDotEnv.m file not found.Once pod Install, it resolved but started getting React/RCTDefine.h not found in multiple libraries.

Please help!

Call function with setState from other component

$
0
0

I have the following setup:

import {getNewImage} from '...'

export default class FirstClass extends Component {
    constructor() {
        super();
        this.state = {
            imageURL: 'www.test.com/new.jpg',
        }
    }

    update = () => {
         this.setState({
             imageURL: 'www.test.com/updated.jpg',
         })
    }

    render() {
        return (
            <View>
                <Image
                    source={{ uri: this.state.imageURL }}
                />
            </View>
        );
    }
}
import Class1 from '...'

export default class SecondClass extends Component {
    render() {
        return (
            <TouchableOpacity onPress={() => new FirstClass().update()}>
                <Class1></Class1>
            </TouchableOpacity>
        );
    }
}

The problem is: it doesn't update the imageURL. I tried multiple things. Logging this inside of update gave back the right object. But trying to log the this.setState() gives an undefinded back.

RNCamera - onFaceDetectionError not working in both Android and iOS

$
0
0

I am not able to find not detecting the face scenario using RNCamera.

dependencies: "react-native": "0.61.5", "react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",

this is how I am using the RNCamera, ....

<RNCamera 
      ref={ref => {this.camera = ref}}
      type={RNCamera.Constants.Type.front}
      onFacesDetected={this.handleFaceDetected}
      onFaceDetectionError = {this.faceDetectionError}
    </RNCamera>
    ...
    handleFaceDetected = (faces) => {
            console.log('face detected!')
        }

    faceDetectionError = (error) => {
            console.log('face Not detected!')
        }

I also faced that even though the camera is not in front of any faces, in some of the android devices it is triggering the onFacesDetected method.

Any help in this is much thankful. Thanks in advance.

React Native AsyncStorage storing values other than strings

$
0
0

Is there any way to store values other than strings with AsyncStorage? I want to store simple boolean values for example.

AsyncStorage.setItem('key', 'ok');

Is no problem, but:

AsyncStorage.setItem('key', false);

Does not work..

reset notification settings in React Native iOS [closed]

$
0
0

I'm building an iOS app with React Native. I want to programmatically reset notification settings when a user deletes their account. This means they should be prompted with a notification grant alert in the process of signing up again.


Cannot receive FCM (Push Notification iOS)

$
0
0

I make app by React Native. Few days ago,I was able to receive FCM. But now I cannot.

Client app permissions notification, I set Xcode(capability),firebase and Apple Developer(APNs setting).

And console.log tells me success.

But I cannot receive notification. Although few days ago I could.

Is this error in firebase??

I don't know cause, please help me m(_ _)m

=======environment==========

Xcode Version 11.3"react-native-firebase": "^5.6.0""react-native": "0.61.5""firebase-admin": "^8.9.0"

How do i build standalone apps that users can open it without Expo client

$
0
0

@brentvatne,

I have a React Native code for iOS and it works perfectly on expo cli. But I keep getting errors when I expo eject it out and run on Xcode, or unable to install the .ipa file with expo build: ios. Every method I tried doesn't work. Then I saw your answer to the post, "What is the difference between Expo and React Native?" and you mention it below.

if you publish it through expo-cli, people can access it at any time through the Expo client on Android or on iOS if signed in to the same account

and

we also make it possible to build standalone apps so people don't have to use the Expo client to open it

I just want my app to be distributed among 20 people and not planning to upload to App Store. In-House distribution is what I need. I have also posted regarding unable to install .ipa into my phone my post, but still unsolved. Could you advise the easiest way to distribute my app? I need a way to install/access the app to iPhones anywhere (Not like TestFlight only 90 days) and easy to update once there is an update.

Hopefully, you will read my post. Anyone who always has the answer as well, please guide me. Thank you all in advance.

Cheers

How solve 'Undefined symbols for architecture armv7' in React Native iOS?

$
0
0

I get a problem to build release react native ios, I try to look for many examples, but fail all.

This is the error message :

Undefined symbols for architecture armv7:
  "_RCTDefaultLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSharedApplication", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSetLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know how to solve this error again, please help me to solve this problem.

Thanks.

Accessibility Identifier issue in ReactNative

$
0
0

I am setting accessibility identifier for my components in react native using testID in iOS and accessibilityLabel in android. For iOS is working fine but for Android it my identifier is appended with , (a comma and a space). I am not sure what is causing issue. Here is my code:

const renderAccessibilityLabel = (str) => {
  const propsForAutomation = {};
  if (Platform.OS === "ios") {
    propsForAutomation.testID = str;
  } else {
    propsForAutomation.accessibilityLabel = str;
  }
  return propsForAutomation;
};

// Inside render method:
<Text {...renderAccessibilityLabel("MyText")}>{MyText}</Text>

result > ios: MyText android: MyText,

I don't know whats wrong with code :(

Can I use react-native for developing maps app

$
0
0

I have a question regarding possibility to uses react-native library for developing the app (ios/android) which will able to support to works with google/apple maps [put points, measure distance, etc] So, the main question is react-native good choice for developing the app with this functionality or instead of this I should use native lang such as (swift/java) ? :)

Viewing all 16563 articles
Browse latest View live