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

How to call iOS photos library from Rust?

$
0
0

I'm interested in doing some low level programming of Rust and React-Native, this tweet by Jared Sumner peaked my interested.

So basically he used the JSI to do a c++ implementation and apparently the results are much much faster than the regular libraries, so I got spelunking and followed some tutorials to get rust code working on a RN project.

Here is my basic rust code:

extern crate libc;

mod string;

use string::StringPtr;

// string ffi

#[no_mangle]
pub unsafe extern "C" fn rust_string_ptr(s: *mut String) -> *mut StringPtr {
    Box::into_raw(Box::new(StringPtr::from(&**s)))
}

#[no_mangle]
pub unsafe extern "C" fn rust_string_destroy(s: *mut String) {
    let _ = Box::from_raw(s);
}

#[no_mangle]
pub unsafe extern "C" fn rust_string_ptr_destroy(s: *mut StringPtr) {
    let _ = Box::from_raw(s);
}

#[no_mangle]
pub unsafe extern "C" fn hello_world(name: *mut StringPtr) -> *mut String {
    let name = (*name).as_str();
    let response = format!("Hello {}!", name);
    Box::into_raw(Box::new(response))
}

#[cfg(feature = "jni")]
#[allow(non_snake_case)]
pub mod android {
    extern crate jni;

    use self::jni::objects::{JClass, JString};
    use self::jni::sys::jstring;
    use self::jni::JNIEnv;

    #[no_mangle]
    pub unsafe extern "C" fn Java_com_mobile_1app_MobileAppBridge_helloWorld(
        env: JNIEnv,
        _: JClass,
        name: JString,
    ) -> jstring {
        let name: String = env.get_string(name).unwrap().into();
        let response = format!("Hello {}!", name);
        env.new_string(response).unwrap().into_inner()
    }
}

I have managed to compile rust code and pass a string to the RN code, the module is registered and I can call the library and get some strings, now however my question is, how do I import the photos module from iOS to get the camera roll photos?

Basically I would like to replace the camera-roll framework with a faster implementation, I would need to figure out how to get the photos.h library working with the rust code though.


React native IOS :axios/fetch request stuck with no error or no response on IOS only

$
0
0

Description:

sending a request with Axios or fetch in IOS not work and it doesn't matter if the API is HTTPS or HTTP no error reaches the catch or no response received also no errors, only warnings

2020-02-18 21:31:21.096 [warn][tid:com.facebook.react.NetworkingQueue][RCTEventEmitter.m:53] Sending `didReceiveNetworkResponse` with no listeners registered.
2020-02-18 21:31:21.100 [warn][tid:com.facebook.react.NetworkingQueue][RCTEventEmitter.m:53] Sending `didReceiveNetworkData` with no listeners registered.
2020-02-18 21:31:21.100 [warn][tid:com.facebook.react.NetworkingQueue][RCTEventEmitter.m:53] Sending `didCompleteNetworkResponse` with no listeners registered.

this only happin with IOS , android works fine

React Native version:

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 40.29 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.15.0 - /usr/local/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.12.0 => 16.12.0
    react-native: 0.61.5 => 0.61.5
  npmGlobalPackages:
    react-native-cli: 2.0.1

Steps To Reproduce

  1. just send any request to any API 2.

Expected Results

get a result or even error from the API

Snack, code example, screenshot, or link to a repository:

the app stuck here because I'm waiting for a result or error from the request image

my simple function

export const checkAuth = (accessToken) => async (dispatch, getState) => {
  try {
    const response = await fetch('https://www.google.com', {
      method: 'GET',
      headers: {
        // Accept: 'application/json',
        // Authorization: `Bearer ${accessToken}`,
      },
    })
    const json = await response.json()
    const { error } = json

    if (error) {
      return false
    }
    return true
  }
  catch (error) {
    return false
  }
}

my info.plist image

Unable to open itms-services url using react-native-webview

$
0
0

I am unable to download the ipa listed on https://m.11086999.com using react-native-webview. The webview shows the following error: enter image description here

The itms link is:

<a href="itms-services://?action=download-manifest&url=https://m.11086999.com/11086.plist" target="_blank" class="btn"><img src="images/right.gif" class="right"

The tag I am using is

<WebView originWhitelist={['*']}  source={{uri: this.state.url}} style={{marginTop:h,flex:1}}/>

Firebase analytics android apps

$
0
0

When implementing fire base analytics in android apps do i need to add any codes in the app side or is it enough to enable it in firebase console only. Does it same in ios

How to copy images from gallery to app’s installation directory in React-native

$
0
0

I want to pick an image from gallery and copy that image to the currently running app’s installation directory using react-native.

PayPal payment integration for REACT NATIVE with latest lib android + ios

LocalNotification not working [IOS] - PushNotificationIOS

$
0
0

I'm trying to implementing local notification in IOS using this @react-native-community/push-notification-ios package.

I followed all the documentation properly. Still, LocalNotification is not working.

This is my environment config: - react-native : 0.61.4 - @react-native-community/push-notification-ios --save : 1.0.5

I did the following things,

  1. npm i @react-native-community/push-notification-ios --save
  2. cd ios && pod install
  3. Updated AppDelegate.m as per described here
  4. Made build : react-native run-ios --device "iPhone X"
  5. Then calling function in my js like this,
import PushNotificationIOS from "@react-native-community/push-notification-ios";
.
.
.
componentDidMount(){
  PushNotificationIOS.addEventListener('localNotification', this._onNotification);

  PushNotificationIOS.requestPermissions();
  PushNotificationIOS.presentLocalNotification({
    alertBody: 'Test Notification'
  });
}

_onNotification(notification) {
  console.log(notification._alert);
}
.
.
.
  • By the way, It requests for permissions when the first-time app opens & also I'm getting console.log of notification but not getting any local notification.

react-native got build error after run pod install because project.pbxproj was updated

$
0
0

I was trying to upgrade react-native from 0.59.9 to 0.61.5

After run react-native upgrade, I follow the upgrade helper instruction and was able to build the project but after that, every time I ran pod install I got this error

error: my-app/ios/Pods/Pods/Target Support Files/Pods-myapp/Pods-myapp.debug.xcconfig: unable to open file (in target "myapp" in project "myapp") (in target 'myapp' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myapp/Pods-myapp.debug.xcconfig: unable to open file (in target "myapp" in project "myapp") (in target 'myapp' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myapp/Pods-myapp.debug.xcconfig: unable to open file (in target "myapp" in project "myapp") (in target 'myapp' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myappTests/Pods-myappTests.debug.xcconfig: unable to open file (in target "myappTests" in project "myapp") (in target 'myappTests' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myappTests/Pods-myappTests.debug.xcconfig: unable to open file (in target "myappTests" in project "myapp") (in target 'myappTests' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myappTests/Pods-myappTests.debug.xcconfig: unable to open file (in target "myappTests" in project "myapp") (in target 'myappTests' from project 'myapp')
error: my-app/ios/Pods/Pods/Target Support Files/Pods-myappTests/Pods-myappTests.debug.xcconfig: unable to open file (in target "myappTests" in project "myapp") (in target 'myappTests' from project 'myapp')

I can fix this by copy and paste project.pbxproj again just like what I already did before. Is there anyway I can do to not copy and paste this every time I run pod install?


How to set a splash screen in react-native app after login

$
0
0

I have a launch screen in my app while launching or opening the app at initially. It was implemented in launchscreen in ios folder.

But how can I implement another splash screen after successful login with my app.

Just say welcome to our app

React Native IOS build clang: error: linker command failed with exit code 1 (use -v to see invocation)

$
0
0

While I'm trying to run the react-native ios application with command react-native run-ios. The Build goes failed and showing me error following:-

ld: warning: directory not found for option '-L/Users/User/Documents/react-test-app/ios/build/Build/Products/Debug-iphonesimulator/React' ld: library not found for -lRNSVG clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed: Ld build/Build/Products/Debug-iphonesimulator/react-test-app.app/react-test-app normal x86_64 (1 failure)

Installing build/Build/Products/Debug-iphonesimulator/react-test-app.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22): Failed to install the requested application The bundle identifier of the application could not be determined. Ensure that the application's Info.plist contains a value for CFBundleIdentifier. Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/oldapollo.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist.

Please Help Me Out To resolve this problem. Thank you in advance

Displaying and (rudimentary) editing of 3D model data in React Native?

$
0
0

Looking at thingiverse.com I came to the conclusion that the minimal requirement is to be able to preview STL file format, but I am open to suggestion concerning the file format.

I am aware of react-stl-viewer which can display, and a couple of github projects based on that. Our aim is to offer a simplistic editor where you add/ union/ delete platonic solids and spheres only without having an active internet connection. What approach (e.g. make, buy, branch) would you suggest? Does it make sense to somehow involve OpenGL?

Microwave Studio Screenshot

Illustration. I would like to be create an object like the grey (cylindric) resonator shown above. Please ignore the magnetic field and all the physical measurements around. I created the model long ago with what is today called CST Microwave Studio

PS: I am aware of https://3dprinting.stackexchange.com/ but this here is an (architectural) programming question.

Control not clicking in iOS react-native

$
0
0

I have this Touchable View in react-native application, presumingly some layer from hierarchy is making that touchable not accessible(clickable), in android the button in working because of elevation property making it on top, but on iOS it won't click on that area.

<ScrollView
        // style={{ backgroundColor: 'green' }}
        refreshControl={
          <RefreshControl
            refreshing={this.state.refreshing}
            onRefresh={this.onRefresh.bind(this)}
          />
        }>
        <View >
          <Text style={styles.heading2}> {this.state.heading2}</Text>


          <View style={styles.daysContainer}>
            <TouchableOpacity
              style={styles.day1}
              onPress={() => {
                this.setState({ selectedDay: '1' });
              }}
              activeOpacity={0.5}>
              <View>
                <Text style={styles.daysTextStyle}>DAY 1</Text>
                {this.state.selectedDay == '1'&& (
                  <View
                    style={{
                      height: 4,
                      width: 30,
                      backgroundColor: Color.VIVID,
                      marginLeft: 32,
                    }}
                  />
      ...

My question is if there is anything that can help make it clickable in iOS too.

Fetch sql data into react-native table component

$
0
0

I need to display specific data - that i get from my sql server database - in table using react native

Please if someone know how to present data dynamic data in table ??

this is my react native page that help me to fetch data and present it (but not like I'm looking for)

 this.state = {
      tableHead: ['Mois','Le nom du client', 'Annee', "Chiffre d'affaire"],
      tableData: [

      ]
    }
  }
  componentDidMount(){
    return fetch('http://192.168.1.4/fetch.php',{
    method:'post',
    header:{
    'Accept':'application/json',
    'Content-type' :'application/json'
    },
    body:JSON.stringify()})
      .then((response) => response.json())
      .then((responseJson) => {

        this.setState({
          isLoading: false,
          dataSource: responseJson,
        }, function(){
        });

      })
      .catch((error) =>{
        console.error(error);
      });
  }
  render() {
    const state = this.state;
    return (
      <View style={styles.container}>
        <Table borderStyle={{borderWidth: 2, borderColor: '#c8e1ff'}}>
          <Row data={state.tableHead} style={styles.head} textStyle={styles.text}/>
          <Rows data={state.tableData} textStyle={styles.text}/>
        </Table>
        <FlatList
        data={this.state.dataSource}
        renderItem={({item}) => <Text>{item.Mois}{"\n"}{item.M500_NOM}{"\n"} {item.Annee } {"\n"}  {item.ChiffreAffaire}{"\n"}{"\n"}</Text>}
        keyExtractor={(item, index) => index.toString()}

        />
      </View>
    )
  }
}

And this is my app page (how my code shows in my app)

How to convert ios native auto layout design to react native design automatically or is there any helper tool?

$
0
0

I have a native iOS project which is designed with auto layout but it has too much screens and i am searching something about the topic. Do you know any converter from auto layout to JSX or do you know any tool even getting help to provide the convertion basically?

The expired sms code immediately after receiving the sms

$
0
0

I have an application that you can log in to by phone number

After entering the phone number I receive an SMS code

A new screen opens where I can enter this code

When I enter the code, I get information that the code is expired

Sign: First screen

  onSignIn() {
    const {code, phoneNumber} = this.state;
    const newNumber = '+' + code + phoneNumber;
    if (newNumber.length > 10) {
      firebase
        .auth()
        .signInWithPhoneNumber(newNumber)
        .then(confirmResult => {
          this.setState({result: confirmResult});
          const navigateAction = NavigationActions.navigate({
            routeName: 'SecurityCode',
            params: {phoneAuthResponse: confirmResult},
          });
          this.props.navigation.dispatch(navigateAction);
        })
        .catch(error => {
          if (error.message === 'TOO SHORT') {
            alert('Please enter a valid phone number');
          } else {
            alert(error.message);
          }
        });
    } else {
      alert('Please Enter Your Number');
    }
  }

Confirm: Second screen

  onConfirmCode() {
    const {securityCode} = this.state;
    if (securityCode.length > 5) {
      this.props.navigation.state.params.phoneAuthResponse
        .confirm(securityCode)
        .then(async user => {
          const ref = firebase.database().ref(`users/${user.uid}`);
          ref.once('value', async snapshot => {
            let data = snapshot.val();
            if (!data) {
              this.props.navigation.navigate('CreateProfile', {
                user: {uid: user.uid, phone_number: user.phoneNumber},
              });
            } else {
              this.props.reduxLoginUser(data);
              this.props.navigation.navigate('InviteContacts');
            }
          });
        })
        .catch(error => console.warn(error.message));
    } else {
      alert('Please enter the 6 digit code');
    }
  }

What is done wrong?


How do you execute Javascript in React-Native WebView?

$
0
0

I'm trying to execute javascript in a WebView that is loaded on an iOS advice. I'm trying to get a painfully simple example to work but it is consistently throwing an undefined or TypeError.

Here is the code:

import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { WebView } from 'react-native-webview';

export default class App extends Component {

  constructor(props){
    super(props)
    this.onPressButton = this.onPressButton.bind(this)
  }

  onPressButton(){
    this.webview.injectJavascript(`alert('hello')`)
  }

  render() {
    return (
      <View style={{ height: '100%' }}>
        <WebView
          ref={ref => (this.webview = ref)}
          javaScriptEnabled={true}
          source={{ uri: 'https://google.com' }}
        />
        <Button onPress={this.onPressButton} style={{ height: '10%' }} title="Test Javascript" />
      </View>

    );
  }
}

Please don't recommend to use injectedJavascript because that is not my desired functionality.

Would appreciate any other approaches as well.

ERROR ITMS-90596: "Invalid Bundle. The asset catalog at 'Payload/ExpoKitApp.app/.bundle/Assets.car' can't be processed."

$
0
0

Problem summary : I would like to submit an app to the Apple App store (TestFlight). I am using Transporter v1.1 to submit the app. I am getting the following error in Transporter during the submission process. Please note that I am not using Xcode in this process.

Actual result: ERROR ITMS-90596: "Invalid Bundle. The asset catalog at 'Payload/ExpoKitApp.app/GoogleMaps.bundle/GMSCoreResources.bundle/Assets.car' can't be processed. Rebuild your app, and all included extensions and frameworks, with the latest GM version of Xcode and resubmit."

Expected result : successful submission to the app store.

Development environment : Expo 36.0.0 / macOS High Sierra v 10.13.6 / Processor 2,3 GHz Intel Core i5 / Transporter v 1.1

What have I tried ? : 1. Deleting all node modules and installing them again (npm install). 2. Deleting any old Xcode folders on my mac. Please note that I am not using Xcode. 3. Checked the version of xcode in package-lock.json. It is 2.0.0 but it is being used as dependancy and not as a direct tool in the submission process. 4. Generate a new build thrice and submitting it once more in Transporter.

Can anyone please help me in this process ? I know this question has been asked before but the case is not applicable to me because I am not using xcode or application loader to submit the app. Any help will be appreciated.

ld: library not found for -lReact-DevSupport after upgrading React Native version to 0.61.5

$
0
0

ld: library not found for -lReact-DevSupport getting this error after upgrading React Native version from 0.60.0 to 0.61.5.

Even I updated pod file as well.

pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'

I tried all, clearing derived data and reinstalling node_module.

Retrieving Device Information React-Native iOS

$
0
0

Hey I am trying to get device information from an iPad. I have tried using https://github.com/rebeccahughes/react-native-device-info but after I do pod install it completely break my solution. Id like to be able to at least get the device's name. How can I go about this without using an NPM module or does anyone know of one that works that doest have to pull in extra dependencies?

Thanks!

GPS location fluctuating in react native

$
0
0

I am using GPS location in one of my app in react native. I need to track user location at some intervals. but I am getting different latitude and longitude. I have already set it for high accuracy. But it does not return the accurate location of the user. Also, I found GPS return different locations in IOS and Android. Please help me with how I can get exact location of the user.

Viewing all 17658 articles
Browse latest View live


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