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

Detox: iOS Simulator how to confirm alert message

$
0
0

I am using Alert from react-native.

How do I get detox to press the "Log out" button on the alert message?

enter image description here

I tried using await element(by.text('Log out')).tap();

But I get "Multiple elements were matched" error. Presumably it finds 3 elements with same label. The original button with label "Log out" used to trigger the alert message, the alert message title, and the alert message button I want detox to press.

Error Trace: [
  {
    "Description" : "Multiple elements were matched: (
    "<UILabel:0x7fe7964db910; AX=Y; AX.label='Log out'; AX.frame={{41, 234}, {238, 20.5}}; AX.activationPoint={160, 244.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{16, 20}, {238, 20.5}}; opaque; alpha=1; UIE=N; text='Log out'>",
    "<UILabel:0x7fe7964dda90; AX=Y; AX.label='Log out'; AX.frame={{198.5, 322.5}, {58, 20.5}}; AX.activationPoint={227.5, 332.75}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 12}, {58, 20.5}}; opaque; alpha=1; UIE=N; text='Log out'>",
    "<RCTText:0x7fe79652f300; AX=Y; AX.label='Log out'; AX.frame={{16, 338.5}, {288, 17}}; AX.activationPoint={160, 347}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 0}, {288, 17}}; alpha=1>"
). Please use selection matchers to narrow the selection down to single element.",
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "5",
    "File Name" : "GREYElementInteraction.m",
    "Function Name" : "-[GREYElementInteraction grey_errorForMultipleMatchingElements:withMatchedElementsIndexOutOfBounds:]",
    "Line" : "956"
  }
]

I guess one way is to use .atIndex(), but that means I need to play with indexes every time something changes to determine the correct element.

Is there no better way to address this issue?

Thanks.


expo build:ios throws Reason: Unknown reason, raw: "SSL_connect returned=1 errno=0 state=error: certificate verify failed"

$
0
0

Yesterday I managed to run the command expo build:ios successfully but this morning it just won't work, I get the following error message after entering my credentials:

Trying to authenticate with Apple Developer Portal...
Authentication with Apple Developer Portal failed!
Reason: Unknown reason, raw: "SSL_connect returned=1 errno=0 state=error: certificate 
verify failed"
Set EXPO_DEBUG=true in your env to view the stack trace.

Any idea where the error comes from? I've checked the apple services status and everything is up.

Here's my setup

Expo CLI 3.11.5 environment info:
System:
  OS: macOS 10.14.5
  Shell: 5.3 - /bin/zsh
Binaries:
  Node: 10.16.3 - /usr/local/bin/node
  Yarn: 1.19.1 - /usr/local/bin/yarn
  npm: 6.9.0 - /usr/local/bin/npm
  Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
  Android Studio: 3.4 AI-183.6156.11.34.5692245
  Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
  @storybook/react-native: ^4.1.7 => 4.1.7 
  @types/react: 16.4.7 => 16.4.7 
  @types/react-native: ^0.60.2 => 0.60.2 
  @types/react-navigation: ^3.0.7 => 3.0.7 
  expo: ^33.0.0 => 33.0.7 
  react: 16.8.3 => 16.8.3 
  react-native: https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz => 0.59.8 
  react-navigation: ^4.0.10 => 4.0.10 
npmGlobalPackages:
  expo-cli: 3.11.5

Error using library react-native-call-detection

$
0
0

I am trying to use the react-native-call-detection library to get the incoming call number.

But when I start the android emulator this low error appears.

I have already run react-native unlink react-native-call-detection, but the error continues. Having identify the other mistakes but to no avail!

If I completely remove react-native-call-detection then the emulator opens without any error.

Can someone help me please?

Thanks.

Microsoft Windows [versão 10.0.18363.535]
(c) 2019 Microsoft Corporation. Todos os direitos reservados.

L:\wAPP\reactCall>react-native run-android
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - react-native-call-detection (to unlink run: "react-native unlink react-native-call-detection")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1645 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

> Task :app:processDebugManifest FAILED

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
21 actionable tasks: 3 executed, 18 up-to-date
L:\wAPP\reactCall\android\app\src\debug\AndroidManifest.xml:11:7-34 Error:
        Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.      
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
L:\wAPP\reactCall\android\app\src\debug\AndroidManifest.xml:11:7-34 Error:
        Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

    at checkExecSyncError (child_process.js:610:11)
    at execFileSync (child_process.js:628:15)
    at runOnAllDevices (L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Command.handleAction (L:\wAPP\reactCall\node_modules\@react-native-community\cli\build\index.js:164:9)        

L:\wAPP\reactCall>  

Open Settings App from another App in iOS - React Native

$
0
0

I'm going through the docs in React Native and can only find navigating to external links from the app I am in.

I want to be able to navigate to the Settings app (more specifically to the privacy > location services page) but, can not seem to find the necessary information on it. There is the native iOS way of doing it which I am trying to replicate through React Native.

Is this possible?

I have tried the following to detect if there is a Settings URL. The console logs that the Settings url works however, it does not navigate to that page.

Update: thanks to @zvona I am now navigating to the settings page but not sure how to get to a specific deep link.

Linking.canOpenURL('app-settings:').then(supported => {

    console.log(`Settings url works`)
    Linking.openURL('app-settings:'
}).catch(error => {
    console.log(`An error has occured: ${error}`)
})

react native write to sms without sending it

$
0
0

I want to write a app to backup and restore sms.

I know I can read sms using react-native, but how can I write the sms to the phone without actually sending it using react-native?

Thanks

How to generate a sports bracket in React Native

$
0
0

I'm making an app in react native that fetches sport data and would display it in a tableau format with nice graphics and user interface.

I know that https://github.com/moodysalem/react-tournament-bracket does pretty much exactly what I need, is there any other tool I can use to make a bracket (single one-on-one elimination) in a mobile app? I'm not very experienced.

Thank you in advance!

React-native ios application build with expo returns error 413 with publish

$
0
0

I have problem with running build react-native application based on expo

expo build:ios returns

Request failed with status code 413
Error: Request failed with status code 413
    at createError (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/adapters/http.js:237:11)
    at IncomingMessage.emit (events.js:205:15)
    at endReadableNT (_stream_readable.js:1154:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)

Thanks a lot for any advice

Getting a RAW from camera in React-native

$
0
0

I don't have much experience in React-Native.

Problem:"Raw" images are required for training the neural network. at the moment, many mobile cameras give the already processed image, which is applied noise reduction, etc., which has a very negative effect on the final image. On modern iPhone 11 devices, noise reduction can be very aggressive and overwrites some objects in the photo.

Can I get RAW in a JS thread ?

Сan I get RAW in a native thread through the implementation of a native module ?

Can this be implemented for both Anroid and IOS.


Styling react native picker - specifically text alignment (iOS)

$
0
0

I have a picker with full screen width and the text is aligned in the center. I want the text to align to the left but having difficulty.

formPicker:{
    marginTop:10,
    backgroundColor:'#eee',
    alignSelf:'flex-start',
    //alignContent:'flex-start',
    //justifyContent:'flex-start',
    //textAlign:'left'
}

<Picker style={styles.formPicker} selectedValue={selectedValue} onValueChange={this.pickerValueChanged}>
                    {pickerItems}
                </Picker>

enter image description here

Property 'overrideUserInterfaceStyle' not found on object of type 'DatePicker *'

$
0
0

I am using react native 0.61.4 and library react-native-date-picker 2.7.3 . I am trying to build the project through xcode and I keep getting this error: Property 'overrideUserInterfaceStyle' not found on object of type 'DatePicker *' in DatePicker.m in three functions. One of these is this one:

- (instancetype)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame])) {
        [self addTarget:self action:@selector(didChange)
       forControlEvents:UIControlEventValueChanged];
        if(@available(iOS 13, *)) {
            self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
        }
    }
    return self;
}

Is this a bug of react-native-date-picker?

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.

React Native drag down to open a top to bottom sliding sheet, drawer, modal, etc

$
0
0

A bottom sheet, drawer, etc. (lots of names, I'll be calling it sheet) is used a lot in apps and there are a lot of RN packages for it. I need one top-down, not bottom-up. The video below shows what I need, but top-down instead of bottom-up.

https://youtu.be/lMo3KI1-9Ps

The image below is a screenshot of the app. The red bar at the top needs to be pulled down to open a second window (this may be a modal). The sheet must be over the tab navigator at the bottom (Home, Subjects, etc.), and must be able to navigate to another page and back. This bar currently sits on a custom header that's loaded via React Navigation's header object. This header receives the navigation prop from the page it's loaded in from. It's no issue if it basically extends the total height of the header to the full page (this will probably the easiest solution). Must work on both android and iOS. We're using expo.

enter image description here

I noticed this package has a height offset which may be quite useful.

EDIT: We're currently testing react-native-slide-down. We'll update the post when we have any results on it.

Automatically adding child dependency pods in React Native

$
0
0

I made a repo sometime back https://github.com/irohitb/react-native-smart-statusbar

Earlier I was using react-native-device-info as a peer Dependency but recently I moved it to the dependencies

Now, When I install this npm repo, the pods associated with the ``react-native-device-info` aren't added to the project and hence it throws following error

Error: @react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps:
  • For react-native <= 0.59: Run `react-native link react-native-device-info` in the project root.
  • Rebuild and re-run the app.
  • If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
  If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-device-info

Can someone help me in figuring out a way when a user installs the repo, pods for react-native-device-infoalso get added?

Module AppRegistry is not a registered callable module

$
0
0

I'm starting with React Native development and I encountered an issue in the very beginning. When trying to run my app I get errors:

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Unhandled JS Exception: Invariant Violation: Native module cannot be null.
Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

My App.js:

import React, { Component } from 'react';
import { SafeAreaView } from 'react-native';
import DefaultRouter from './src/navigation/DefaultRouter'

export default class App extends Component {
  render() {
    return (
      <SafeAreaView>
        <DefaultRouter />
      </SafeAreaView>
      );
    }
  };

index.js:

import { AppRegistry } from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

DefaultRouter.js:

import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import LoginScreen from '../screen/LoginScreen';
import DefaultTabBar from '../navigation/TabBar';

const DefaultRouter = createSwitchNavigator({
    LOGIN_SCREEN: {
        screen: LoginScreen
    },
    TAB_NAVIGATION: {
        screen: DefaultTabBar
    }
}, {
    initialRouteName: 'LOGIN_SCREEN',
    headerMode: 'none'
})

export default createAppContainer(DefaultRouter)

Other files are simple Component subclasses.

The issue manifests regardless if I run the app from Visual Studio Code or from terminal with react-native run-ios

I looked through existing answers and I didn't find anything that could point me in the right direction:
React-Native: Module AppRegistry is not a registered callable module
React Native: Module AppRegistry is not a registered callable module (calling runApplication)
module appregistry is not a registered callable module (calling runApplication)Module AppRegistry is not a registered callable module and Cant find variable: Constants
React Native Module AppRegistry is not a registered callable module
Module AppRegistry is not a registered callable module only in Release configuration

I'm stuck and I don't know where to go from here

React Native XCode (objc[1284]: Class CLSUserDefaults is implemented in both /System/Library/Frameworks/ClassKit.framework/ClassKit) (NO CocoaPods)

$
0
0

My app is using the latest react-native-fabric(version 0.5.2) and I am trying to run it on my iPhone which is using IOS 13.3. However every time I try to run it through XCode Version 11.3 (11C29) onto my device, XCode throws that error message you see below in the XCode console which prevents my app from completely starting.

Weird part is that XCode builds and starts the app perfectly fine on a Simulator & iPad with the same IOS 13.3.

Error message that comes up in the XCODE:

objc[1284]: Class CLSUserDefaults is implemented in both /System/Library/Frameworks/ClassKit.framework/ClassKit (0x1caeb9d40) and /private/var/containers/Bundle/Application/7D65B3-D92B-4BFE-B128-DD84889E7CA2/MyApp.app/MyApp (0x100fdfda0). One of the two will be used. Which one is undefined. 2020-01-14 15:52:32.132510-0800 MyApp[1284:863494] [Crashlytics] Version 3.9.3 (128)

Now Iv'e done extensive research all over Google, Stackoverflow, Github, Blogs and so on about this issue but I have yet to see a solution for this with React Native < 6.0which is NOT using CocoaoPods.

Right now I am on React Native version 0.59.9, therefore I do NOT have Cocoapods available.

Reason I bring this up is because I have seen simple solutions on Stackoverflow of people say "Just update your Crashlytics version and Fabric version in your Pods file". And while that may have worked for some for others that is not even an option.

Aside from that I have tried multiple other things such as,

  • Clearing Cache in XCode
  • Deleting DerivedData Folder
  • Restarting Computer and Device
  • Uninstalling the app and clearing cache on device
  • Different XCode versions 11.1, 11.2, 11.3 and when you go below 11 XCode alerts you and tells you that it wont be able to build the app on IOS 13 with an XCode version below 11.

If anyone has any ideas please feel free to share, thank you!


Requiring Modules in react-native

$
0
0

I'm stuck on a problem in a react-native project. I'm trying to do a general require file, where I export all my modules. After that I would like to require only my "require.js" file to avoid calls like this require('../../ModuleName') in every file.

I have 4 files:

index.ios.js
/app/home.js
/app/MyView.js
/app/require.js

require.js:

module.exports = {

    Home: require('./home'),
    MyView: require('./MyView')

}

in index.ios.js (he modules Home and MyView are getting importet correctly)

'use strict';

var React = require('react-native');
var {
    AppRegistry,
    StyleSheet,
    Text,
    View,
} = React;

var {
    Home,
    MyView
} = require('./app/require');

class Test_require extends React.Component {

    render() {

        return(
            <Home />
        );
    }

}



AppRegistry.registerComponent('Test_require', () => Test_require);

Home.js (the module MyView is not getting importet)

'use strict';

var React = require('react-native');

var {
    View,
    Text
} = React;

var {
    MyView
} = require('./require');

class Home extends React.Component {

    render() {
        console.log(MyView);
        return(
            <MyView />
        );
    }

}

module.exports = Home;

In the Home.js the MyView variable is "undefined". If I want to require a module in a Module, that gets already imported in another file, the variable is undefined.

Do you guys have any clue why I can do this or is there a better solution for my problem? Thanks for any clue

react-native Keyboard.dismiss() not working after autofill on iOS

$
0
0

I am developing a react-native app using expo.

On my signIn screen I do have two TextInputs (with textContentType username and password). I do have multiple places where I'm calling Keyboard.dismiss() (from a wrapping Touchable, from other Buttons etc.) which works fine for most usecases.

My problem is that after I successfully used password autofill on iOS (via fingerprint) first the keyboard hides and reshows automatically (fireing all the usual keyboard events) which looks strange but is acceptable but afterwards the keyboard is no longer reacting to any Keyboard.dismiss() calls untill I focus another TextInput.

There seems to be a similar issue with the "use strong password" keyboard overlay.

Here my versions:

"expo": "^34.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",

Running in the Expo client on iOS 13.2.3

Thank you in advance for any help.

How to disable back button after splash screen in React Native

$
0
0

after I finished loading the splash screen and going to the main page, I pressed it back again to go back to the splash screen ..

and the question is how to overcome this, so that after entering the main page I can't go back to the splash screen either from the button or back button on the phone keyboard,

Thanks in advance ..

How can I change Ticketmaster login Header text in react-native?

$
0
0

I want to change header of ticketmaster login header text . While I am passing displayName as empty string ("") in PresenceSDK , my application is crashing.
So any other place to change ??

current text : Sign in with your Office account or Ticketmaster account

Expected : Sign in with your Ticketmaster account

PresenceSDK.getPresenceSDK().setConfig(consumerKey: consumerKey, displayName: "Office account");

React Native: Error decoding image data from CameraRoll.saveToCameraRoll

$
0
0

I'm getting a warning sign, saying

Possible: Unhandled Promise Rejection: Error: Error decoding image data

This is my code.

for (let media of mediaArray) {   
  await CameraRoll.saveToCameraRoll(
    'https://someurl.mp4',
  ); 
}

I was able to get this to work with a url that has a .jpg, but when I tried a .mp4 url, it doesn't work. I know the url is correct, but not sure why I'm getting this? Am I missing something if I have to save both either photo or video?

Viewing all 16558 articles
Browse latest View live


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