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

react-native: command not found

$
0
0

I am getting -bash: react-native: command not found error while creating react-native project.

Below are the additional info

1. brew --version
   homebrew 0.9.9
2  brew info watchman
   watchman `enter code here`stable 4.50
   /usr/local/Cellar/watchman/4.4.0
3. brew info flow
   stable 0.24.1
   /usr/local/Cellar/flow/0.24.1
4. brew info node
   stable 6.1.0
   /usr/local/Cellar/node/6.1.0
5. npm -version
   3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I tried suggested steps from the below link but still i am getting same error.

  1. react-native-command-not-found

I don't have any "npm" directory which they have specified in the solution

Ashoks-MacBook-Pro:share Ashok$ ls
aclocal     doc     info        ruby-build  zsh
autoconf    emacs       man     systemtap

But i found npm file exist in below location.

/usr/local/Cellar/node/6.1.0/etc/bash_completion.d

I uninstalled react-native and installed again but still i am facing same issue.


Composite Image React Native?

$
0
0

I have a lot of different images in .png format.

I would like to stack all these different images together to get one single image that I can display with the Image component of React Native.

The goal is to be able to generate a single different image according to the given parameters!

I've been searching for hours on the Internet but I can't find any way to do this!

Is there a module to do this?

Thank you

Viktor

gestureState and nativeEvent difference

$
0
0

I am trying to use React Native's PanResponder. In its callback functions there are two parameters that can be invoked: event and gestureState. If I log the event.nativeEvent, and the gestureState object there are keys which have the same values (eg. pageX and moveX), and there are different keys. What I don't understand is the reason for using 2 callback parameters and not one object containing all the keys. I'm sure it must have its reasons, but what are those? Can somebody explain it and give some examples?

Why am I getting this error in Expo when trying to scan QR code?

$
0
0

I get the following error when I try to open my expo project on my iPhone

"There was a problem running the requested app. It looks like you may be using a LAN URL Make sure your device is on the same network as the server or try using a tunnel"

Both my phone and laptop are connected to the same WiFi

I'm not sure what I did wrong. All I have done so far is run the following commands:

npm install expo-cli --global

expo init rn-first-app

npm start

React Native: Could not connect to development server

$
0
0

I have a very simple React Native project that I am trying to get working. It is an iOS project that simply adds a RCTRootView to a UIViewController. When I run the app from Xcode I get a red screen with the error:

Could not connect to development server.

Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate

AppDelegate.h

@property (strong, nonatomic) RCTRootView *rootView;

AppDelegate.m in application: didFinishLaunchingWithOptions:

NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];
self.rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"HelloReact" initialProperties:nil launchOptions:launchOptions];

ViewController.m in viewDidAppear:

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self.view addSubview:delegate.rootView];

I am at a loss on how to resolve this. I have tried all of the following:

  • npm start
  • npm start --reset-cache
  • Deleted node_modules directory and reinstalled
  • Uninstalled and reinstalled node, watchman, react-native, and npm
  • Tried on physical device and simulator

Does anyone see anything that is wrong in my code or know what the issue might be? I'd be willing to converse over email or phone to solve this. I am getting desperate.

I was having simultaneous issues. Here is the other question I asked which may contain some info: React Native: Unable to Resolve Module

Reverse TCP for IOS device?

$
0
0

I'm trying to develop a react-native application, sometimes it is saying cannot connect to the development server. As I read that executing the react-native project in IOS doesn't needs reverse tcp to accept requests from a development server.

can we do a reverse tcp on an IOS device?

Thank you in advance.

AR with React Native

$
0
0

So the question I have is about the augmented reality in react native. I know there is ARKit (IOS only) and ARCore (Android only). It also has the expo AR library (which is what I use in the service). But none of them found anything about using Marker / Image based to scan the image and present an object. I was able to find these features on AR.JS, but it's only for the internet.

Here comes the question: Is there any way for webView to access a page made with AR.JS? I tried but even enabling the camera the page does not load, either iOS or android.

Example on Git: https://github.com/iondrimba/augmented-reality

It has the link to test AR.js or use in webview for those who can.

If not, do you have a library that enables AR Marker in react native?

I'm new to mobile development, but I was interested to know about AR, if they can help thank you very much !!

Where to locate expoClientID and iosCliendID and other Bundle ID?

$
0
0

I'm trying to implement the Google OAuth in my Expo app. expo-google-app-auth requires expoClientId, iosClientId, androidClientId, Bundle ID, etc, but I'm having difficulty locating this information. I'm using Expo only and I'm not using Xcode due to that fact that I'm new to React Native. Is this information I can only obtain when I build the standalone app? When I look at app.json, this information doesn't exist.


Google OAuth in React Native doesn't logout

$
0
0

I'm setting up the Google OAuth using Expo's expo-google-app-auth and I have no problem with the login process, but I'm having difficulty logging out.

    import * as Google from 'expo-google-app-auth'

    const [accessToken, setAccessToken] = useState('')
    const storeToken = async (token) => {
        try {
            await AsyncStorage.setItem(token, GOOGLE_TOKEN)
        } catch (err) {
            throw new Error(err)
        }
    }

    const signInWithGoogleAsync = async () => {
        try {
            const result = await Google.logInAsync({
                iosClientId: IOS_CLIENT_ID,
                scopes: ['profile', 'email'],
            });

            if (result.type === 'success') {
                storeToken(result.accessToken)
                setAccessToken(results.accessToken)
            } else {
                return { cancelled: true };
            }
        } catch (e) {
            return { error: true };
        }
    }

    const signoutWithGoogleAsync = async () => {
        try {
            console.log("token in delete", accessToken)
            await Google.logOutAsync({ accessToken, iosClientId: IOS_CLIENT_ID })
        } catch (err) {
            throw new Error(err)
        }
    }

Following is how I login and logout:

<TouchableHighlight onPress={() => signInWithGoogleAsync()}>
            <Text>Login with Google</Text>
        </TouchableHighlight>
        <TouchableHighlight onPress={() => signoutWithGoogleAsync()}>
            <Text>Logout</Text>
        </TouchableHighlight>

However, when I logout, there are no errors, but doesn't log out of the Google's account. When I click on login button again, the login process doesn't require inputting the password.

react native ios build succeeds but path to app bundle is wrong

$
0
0

When I run react-native run-ios build succeeds and created build folder under ios. But after build, when installation starts, get the below error. The project runs successfully when I run it through xcode. What I observed is that path beginning 'DerivedData' is wrong. Instead it should be 'build'. When I rename my 'build' folder to 'DerivedData' and re-run 'react-native run-ios' the whole process completes successfully but of course with the previous build.

How can I change the 'DerivedData' to 'build'?

This error occurred immediately after I upgraded from 0.59.9 to 0.60.0.

Error: info Installing "DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app" An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2): Failed to install the requested application An application bundle was not found at the provided path. Provide a valid path to the desired application bundle. Print: Entry, ":CFBundleIdentifier", Does Not Exist error Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist . Run CLI with --verbose flag for more details. Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist

at checkExecSyncError (child_process.js:616:11) at Object.execFileSync (child_process.js:634:13) at runOnSimulator (/Users/armaneker/WebstormProjects/mobileappname/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:189:45) at process._tickCallback (internal/process/next_tick.js:68:7)

React Native version: System: OS: macOS 10.15 Binaries: Node: 10.15.3 - /usr/local/bin/node npm: 6.13.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0 Xcode: 11.0/11A420a - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.0 => 0.60.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7

Steps To Reproduce

  • used rn-diff-purge to upgrade from 0.59.9 to 0.60.0
  • android worked correctly
  • react-native run-ios build succeeded but installation of app failed

libc++abi.dylib: terminating with uncaught exception of type NSException, React Native iOS

$
0
0

Issue Description::

I am working on react-native-ios app, most of the times it stuck after splash. I have created a duplicate splash screen inside my react native code. When app started I am redirecting it to dummy splash screen which is exactly like a splash. Here I am loading complete required data of app from API. After loading complete data I am pushing it initial screen. But most of the time my stuck after splash screen, or sometimes crash after loading splash(when moving from original splash to dummy splash screen where I am loading whole app required data).

There is no error inside terminal, I am getting this following mentioned error inside xcode output window, whenever my app crashed or when app stuck on splash screen.

Error::

  • Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

  • libc++abi.dylib: terminating with uncaught exception of type NSException

My iOS app working working fine if I am redirecting to login screen, but having issue whenever i am redirecting to dummy splash. I have also changes my dummy screen name to "initializer.js" but nothing happened. iOS app crashed or stuck after splash it redirecting it to screen where i am loading complete required data for app.

App Intializer Screen Code(dummy splash)::

/**
 * Splash Screen
 */
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import * as Animatable from 'react-native-animatable';
import { View, Text } from 'react-native';
import { Spinner } from 'native-base';
import Toast from 'react-native-simple-toast';
import NetInfo from '@react-native-community/netinfo';
import SplashScreen from 'react-native-splash-screen';
import AsyncStorage from '@react-native-community/async-storage';
//Global Components
import { ImageView } from '../../Components/GlobalComponent';
//Form Components
import { Button } from '../../Components/FormComponent';
// APIResponseMessages
import APIResponseMessages from '../../Constants/APIResponseMessages';
// Actions
import { appInitialize, loader } from '../../Actions';
//Style
import { GlobalStyles, Colors } from '../../Styles';
//Images
import Images from '../../Assets/Images';
//Navigation Screen
import { AUTH, INITIAL_SCREEN, setRootScreen } from '../../Navigation';
import LocalStorageKeys from '../../Constants/LocalStorageKeys';
// singleton class
import APIURLServiceSingleton from '../../Services/APIURLService';
// Strings
import { en } from '../../Strings';
//Base Controller
import BaseController from '../BaseController';

const { overlayContainer, flex1, w100, mb30, h100, justifyContentCenter, alignItemsCenter, mb20, px20, px10, textWhite, textCenter } = GlobalStyles;

class Splash extends BaseController {
    state = {
        showTryButton: false,
    };

    isConnected = false;

    /*
    * lifecycle method called when component mount
    */
    componentDidMount() {
        NetInfo.isConnected.addEventListener('connectionChange', this._handleConnectionChange);
        // hide splash screen

        setTimeout(() => {
            SplashScreen.hide();
            NetInfo.isConnected.fetch().done((isConnected) => {
                this._handleConnectionChange(isConnected);
                this.initializeApp();
            });
        }, 1000);
    }

    /**
     * Function to initialize Application
     */
    async initializeApp() {
        if (this.isConnected) {
            //...... connection code here
        } else {
            Toast.showWithGravity('Please check your internet connection and try again.', Toast.LONG, Toast.CENTER);
        }
    }

    /*
    * lifecycle method called when component unmount
    */
    componentWillUnmount() {
        NetInfo.isConnected.removeEventListener('connectionChange', this._handleConnectionChange);
    }

    /**
     * Function to handle connection change
     */
    _handleConnectionChange = (isConnected) => {
        if (isConnected) {
            this.isConnected = isConnected;
        } else {
            this.isConnected = isConnected;
            this.setState({ showTryButton: true });
        }
    };

    /**
     * Function called on try again
     */
    async onTryAgain() {
        if (this.isConnected) {
            this.setState({ showTryButton: false });
        }
        await this.initializeApp();
    }

    // render method
    render() {
        const { showTryButton } = this.state;
        const { serverError } = this.props;
        return (
            <View style={[flex1]}>
                <ImageView style={[overlayContainer, w100, h100]} resizeMode="cover" source={Images.splash} />
                {..... my other code here}
            </View>
        );
    }
}



export default connect(null, { appInitialize, loader })(Splash);

My AppDelegate.m file::

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import "RNSplashScreen.h"


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
  [RNSplashScreen show];

  return YES;
}

@end

Environment Description::

  • "react-native": "0.61.4"
  • "react": "16.12.0"
  • "react-native-navigation": "3.5.1"
  • "react-native-splash-screen": "3.2.0"

  • xcode: 11.2.1

my react native project does not contained any app.xcworkspace file in iOS

$
0
0

I want to run my react native app. when I run it by Xcode it shows something linker error and solution of that finds running by xcworkspace file.

something happens when I run this by react-native run-ios command

And in my project this file is not there in iOS folder.

react-native version: 0.60.4

Delete application data on iOS simulator without uninstalling app?

$
0
0

I would like to delete application data like local storage without reinstalling the app.

I am using AsyncStorage in react-native, and have persisted some data. To quickly test storage, I would like to be able to clear AsyncStorage manually through the simulator, without implementing a logout/ clear AsyncStorage button in the app.

It seems like the iOS simulator is rather limited compared to Android Emulator. e.g. An unrelated problem about iOS simulator: Even clearing the store when its empty causes errors.

Using Typekit (Adobe) fonts on React Native project?

$
0
0

I recently opened some mobile app mockups that I have to develop. I'm using React Native (with Expo). The thing is, this mockups use a lot of Adobe fonts (Typekit).

I came across the doc: https://helpx.adobe.com/fonts/using/embed-codes.html, that can be used on web apps, not on compiled mobile apps.

I can't find any questions about it, but I wonder how mobile apps dev are implementing Typekit fonts in their projects?

React Native Expo Ejected App, can't get push token from Device

$
0
0

I use Expo push Notifications to send Notifications to GSM using push token. My code is :

  registerForPush = async () => {
    if (Constants.isDevice) {
      const { status: existingStatus } = await Permissions.getAsync(
        Permissions.NOTIFICATIONS,
      );
      let finalStatus = existingStatus;
      if (existingStatus !== 'granted') {
        const { status } = await Permissions.askAsync(
          Permissions.NOTIFICATIONS,
        );
        finalStatus = status;
      }
      if (finalStatus !== 'granted') {
        alert('Failed to get push token for push notification!');
        return;
      }
      const gsm = await Notifications.getExpoPushTokenAsync();
      this._storeData('TOKEN_GSM', gsm);
    } else {
      alert('Must use physical device for Push Notifications');
    }
  };

async componentDidMount() {
this.registerForPush();
}

When i use Expo to run the App i granted manually the permissions to get the token, but now i ejected to app to run IOS project with Xcode. I got an error that i can't get push token : Failed to get push token for push notification


Apple login not giving email id [closed]

$
0
0

I have a react native app with social logins ( Facebook and Gmail ). Because of the new apple policies update, we need to integrate apple login for uploading it to the app store.

We are already done with it, but the issue is when the user installs the app very first time and selects apple login it's not sharing email id in response consistently.

Very few times, it gives the share my email option but maximum times it's not giving that screen.

The following screen shows the working scenario.

enter image description here

The following screen shows the option which is coming consistently and not giving an email.

enter image description here

If anyone knows about it, please let me know.

Thanks,
Sopo

How to Integrate Crashlytics with React Native app

$
0
0

I'm building my app using React Native and I want to catch crashes that happen on both Objective-C and JavaScript sides of the app.

I installed Crashlytics SDK using their guide and installer and everything went smooth. I do get to see crashes from the Objective-C side, but not crashes that occurs from JavaScript.

Do I need to do something special to catch JavaScript errors and report them to Crashlytics?

Thanks, Ran.

Type Error: null is not an object (evaluating KontakModule.stopDiscovery')

$
0
0

An error occurred

Type Error: null is not an object (evaluating KontakModule.stopDiscovery')

because

import Kontakt, { KontaktModule } from 'react-native-kontaktio';

after installing 'react-native-kontaktio'

What I have tried and it didn't work out:

Version

  • react: 16.9.0
  • react-native-cli: 2.0.1
  • react-native: 0.61.5
  • react-native-kontaktio: 2.7.0

I have tried using this library on Android and it worked perfectly. I really need help on this because I'm just a year 2 student and I need to add a feature on an app to scan for beacons nearby as soon as possible. I have no clue why does this happens but the problem is probably due to linking and compiling libraries because it is saying that a function imported is null (I tried to comment out each function one by one and I can conclude that all of the functions are null.

React Native width on tablet

$
0
0

I have created a new react-native app

npx react-native run-ios --simulator="iPad Pro (9.7-inch)"

and added the code found here:

medium link

The app looks like this on the iPad simulator:

imgur image

How can I set it to full width?

Firebase Performance Monitoring React Native integration

$
0
0

I have install Firebase Performance monitoring on my React Native app and integrate it successfully. After i want to track my network requests performance and go through as documentation.

const trackRequest = async (url,method) => {
    // Define the network metric
    const metric = await perf().newHttpMetric(url, method);

    // Define meta details
    metric.putAttribute('testAttr', 'testValue');

    // Perform a HTTP request and provide response information
    const response = await fetch(url);
    metric.setHttpResponseCode(response.status);
    metric.setResponseContentType(response.headers.get('Content-Type'));
    metric.setResponsePayloadSize(response.headers.get('Content-Length'));

    // Stop the trace
    await metric.stop();

    return response.json();
};

I use this function from documentation and call it every network requests time

fetch("www.example.com")
trackRequest("www.example.com","GET")

Can anyone explain me what i were doing wrong ?

Viewing all 16558 articles
Browse latest View live


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