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

Is it possible to show 10-second loading screen after button is pressed in React Native?

$
0
0

I need to show loading screen when press button (until app get data from API) for cca. 10 seconds.

Is it possible and how to do that?


Getting shortcut on the folder in node modules while installing the package from local directory

$
0
0

Am trying to create an new library and trying to add in my project, my library source is in below path file:../react-native-svm-camera .

In my package.json inside the directory i have "dependencies": { "react": "16.9.0", "react-native": "0.61.5", "svm-camera": "file:../react-native-svm-camera" } Am installing the above as react-native install react-native-svm-camera, the package got successfully installed and am able to view in the node modules.But the problem is the folder is viewed as shortcut and getting error when importing the module.

What is the reason for getting shortcut in the folder? correct me if anything wrong in the implementation.

Please find the attached image for the reference. enter image description here

How to use Xcode in Ubuntu 18.04?

$
0
0

I'm using react-native to build an app and Xcode is not supported on Ubuntu. So, I can't develop ios apps. Is there any way around so that I could run an ios simulator without having a Mac? I found articles where they suggested to use a virtual box but I think it's not efficient to develop apps on a virtual box(just an intuition). Hackintosh is not an option for me. So, Is there any other way to run an ios simulator?

react-native-share only social share whatsapp cannot run in ios

$
0
0

Hi i'm have problem using react-native-share only in ios and only in social whatsapp.If i use singleshare the whatsapp social cannot open & error, and if use multiple share there nothing happen when i click whatsapp. I already added LSApplicationQueriesSchemes but still error.

This is my LSApplicationQueriesSchemes :

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
    <string>whatsapp</string>
</array>

And i already follow the step for installation still not working, by the way i use cocoapods installation.

Please help!!!

Changing initialRouteName dynamically when navigating between StackNavigators (Nested Stack)

$
0
0

I have used multiple StackNavigators inside a single StackNavigator. I want to navigate to a specific screen in a stack instead of the initialRouteName defined when navigating.

I have tried the StackActions / NavigationActions with navigation.dispatch(). But could not solve the issue.

const firstStack = createStackNavigator({
firstScreen: firstScreen,
secondScreen: secondScreen
},
{initialRouteName: 'firstScreen'});

const secondStack = createStackNavigator({
thirdScreen: thirdScreen,
fourthScreen: fourthScreen
},
{initialRouteName: 'thirdScreen'});

const appStack = createStackNavigator({
firstStack: firstStack,
secondStack: secondStack
});

I want to navigate from firstStack - firstScreen to secondStack - fourthScreen.

iOS simulator doesn't launch my app

$
0
0

I've installed the create-react-native-app, however I am facing an issue with my iOS simulator. It launch well but doesn't open my app and stay in the home screen. My android emulator behave as expected and the app is directly displayed. I've installed and updated XCode. The default device is an iPhone X but if i set to iPhone 6, it still open an iPhone X simulator.

Any suggestions ?

React Native multi line TextInput, text is centered

$
0
0

So when using, text input with multiline=true, I have this issue where the text is vertically centered instead of being pushed to the top.

This issue happens on both ios and android, except android has another issue where, when multiple lines are entered, they get letterboxed to the height of 1 line.

I'd like to point out, I have tried adding textAlignVertical: 'top' to the style of the textinput

Code: (I have this as a seperate copmonent as I use it in forms with form text but all parameters are passed something)

<TextInput
            style={styles.input}
            value={value}
            autoComplete={autoComplete}
            autoCapitalize={autoCapitalize}
            placeholder={placeholder}
            secureTextEntry={secureTextEntry}
            keyboardType={keyboardType}
            returnKeyType={returnKeyType}
            autoFocus={autoFocus}
            onChangeText={onChangeText}
            onSubmitEditing={onSubmitEditing}
            multiline={multiline || false}
            ref={(r) => { inputRef && inputRef(r); }}
    />

styles:

input: {
    paddingRight: 10,
    lineHeight: 23,
    flex: 2,
    textAlignVertical: 'top'
},

ios screenshot

android screenshot

React-native-navigation hide navigation bar on login screen?

$
0
0

I am using the react-native-navigation in my react-native application for navigation. I wanted to hide navigation bar on first screen I tried

{ navBarHidden: true}

The complete code for navigation is:

 Navigation.startSingleScreenApp({
    screen: {
        label: "Login",
        screen: "LoginComponent",
        icon: require('./asset/menu.png'),
        title: "Login",
      }, 
      navigationBarStyle : {navBarHidden: true },
      passProps: {},
      animationType: 'slide-down'
  });

Not showing any error and still can see the navbar on my login screen.


RNFirebaseNotifications.h not found after migrating to firebase v6. React Native

$
0
0

I am migrating to a new version of RN and firebase as well . I did everything as it is written in migration guideline of firebase v6 but now, xcode shows me error 'RNFirebaseNotifications.h' file not found and RNFirebaseMessaging.h file not found. Since RN > 0.60 uses auto linking, can it be the reason that xcode cannot find required modules ? If you know how to solve the issue, please, let me know. My package.json

"dependencies": {
"@react-native-community/async-storage": "^1.7.1",
"@react-native-community/netinfo": "^5.0.1",
"@react-native-firebase/app": "^6.2.0",
"@react-native-firebase/messaging": "^6.2.0",
"@tinkoff/utils": "^1.0.2",
"buffer": "^5.2.1",
"connected-react-navigation": "^0.0.4",
"formik": "^1.5.2",
"jetifier": "^1.6.4",
"moment": "^2.22.2",
"react": "16.9.0",
"react-dom": "^16.8.6",
"react-native": "0.61.5",
}

Unfortunately, I've not found any solution on firebase github page :(

How to set ReactNative app as default system app?

$
0
0

Actually, I am working on a ReactNative app like TrueCaller.

The problem is how to show the received call in my app instead of the default system UI?

Regards

Wrong verifying Code from sms - react native

$
0
0

I have Text Input

<TextInput
            value={''}
            ref={ref => {
              this.refPassword = ref;
            }}
            onChangeText={value => this.handleChange(value)}
            textContentType="oneTimeCode"
            onKeyPress={this.handleKeyPress}
            keyboardType={'number-pad'}
            style={[
              styles.textInput,
              {
                left: selectedIndex * wp('15%'),
                opacity: hideInput ? 0 : 1,
              },
            ]}
          />

handleChange(value) {
this.setState(
  state => {
    return {
      value: (state.value + value).slice(0, CODE_LENGTH.length),
    };
  },
  () => {
    if (this.state.value.length >= CODE_LENGTH.length) {
      this.completePassword();
    }
  },
);

}

But, i receive code from sms is incorrect.

Code from SMS: 113498

Code Autofill: 111113

What am I doing wrong?

React native app crashes on sendEventWithName

$
0
0

I am trying to send data from objective C to react native. I have already achieved that in other occasion with this function:

-(void)loginData:(NSString *) data
{
  [self sendEventWithName:@"loginOrRegister" body:data];
}

+ (id)allocWithZone:(NSZone *)zone {
    static CosmoteIdHelper *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [super allocWithZone:zone];
    });
    return sharedInstance;
}

I tried to do it again with function:

-(void)editProfile:(BOOL) success
{
  [self sendEventWithName:@"editUserProfile" body:@{@"data": @(success)}];
}

but app crashes with "Thread 1: signal SIGABRT". I can't tell if I have forgotten something but I am pretty sure I haven't. I have tried to send a simple string but nothing.

In react-native i have an emitter like this:

const eventEmitter = new NativeEventEmitter(NativeModules.CosmoteIdHelper);
      eventEmitter.addListener('editUserProfile', (event) => {
                           ....

Prevent RNFirebase requesting notification permissions until button pressed

$
0
0

I'm using Firebase with FCM for React Native. I have a set of onboarding screens. Half way through it explains why we need to send notifications and should then show the alert that requests the permissions.

However, it seems that just including the line [RNFirebaseNotifications configure]; in my AppDelegate.m makes it do it on installation of the app. I imagine though that removing this will just entirely stop Firebase Messaging from working!

How do I make it only request the permissions when I want it to, with firebase.messaging().requestPermission();?

Here is my AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#if RCT_DEV
  #import <React/RCTDevLoadingView.h>
#endif

#import <CodePush/CodePush.h>
#import "RNSplashScreen.h"
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"

#import <AppCenterReactNative.h>
#import <AppCenterReactNativeAnalytics.h>
#import <AppCenterReactNativeCrashes.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  #if RCT_DEV
    [bridge moduleForClass:[RCTDevLoadingView class]];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"foobar"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  // Instantiate and configure Firebase.
  [FIRApp configure];
  // Configure the Firebase react-native notifications.
  [RNFirebaseNotifications configure];

  // Register Microsoft App Center.
  [AppCenterReactNative register];
  [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];
  [AppCenterReactNativeCrashes registerWithAutomaticProcessing];

  if ([UNUserNotificationCenter class] != nil) {
    // iOS 10 or later
    // For iOS 10 display notification (sent via APNS)
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
    UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
      UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
    [[UNUserNotificationCenter currentNotificationCenter]
      requestAuthorizationWithOptions:authOptions
      completionHandler:^(BOOL granted, NSError * _Nullable error) {
          // ...
      }];
  }
  else {
    // iOS 10 notifications aren't available; fall back to iOS 8-9 notifications.
    UIUserNotificationType allNotificationTypes =
    (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
    UIUserNotificationSettings *settings =
    [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
    [application registerUserNotificationSettings:settings];
  }

  [application registerForRemoteNotifications];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [RNSplashScreen show];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [CodePush bundleURL];
#endif
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler
{
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}

-(void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
  [[RNFirebaseMessaging instance] didReceiveRemoteNotification:response.notification.request.content.userInfo];
  completionHandler();
}

@end

Thanks in advance.

Can't compile React Native iOS app to run on physical device, issue with React Native Firebase

$
0
0

For some reason since recently, I cannot run my React Native app on a physical device from Xcode or even from the command line. I'm getting the following error:

duplicate symbol '_md5_block_data_order' in:
    /XXX/Library/Developer/Xcode/DerivedData/XXXX-bdrylwsxpcqgzvgkcljteyttcdmr/Build/Products/Debug-iphoneos/BoringSSL-GRPC/libBoringSSL-GRPC.a(md5.o)
    /XXX/project/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(md5_dgst.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

However it works fine from a simulator. And I can upload the app to AppStoreConnect without any issue.

From what I understand it looks like the same symbol exists in 2 libraries. Not sure why, most likely one of the mobile app dependencies.

In the list of Pods installed I have both BoringSSL-GRPC (0.0.3) and OpenSSL-Universal (1.0.2.19)

BoringSSL is used by Firebase and OpenSSL is used by Flipper.

This is the list of third party dependencies I use:

  pod 'Firebase/Core', '~> 6.3.0'

  pod 'Firebase/Messaging', '~> 6.3.0'

  pod 'Firebase/Firestore', '~> 6.3.0'

  pod 'Firebase/Auth', '~> 6.3.0'

  pod 'TrustKit'

  pod 'Stripe', '16.0.0'

  pod 'Amplitude-iOS', '~> 4.5'

  pod 'Intercom', '~> 5.5.1'

  flipper_pods()

When I remove Firebase all together, it works fine and I can run my app on the device. But I need Firebase...

Any idea how to resolve this?

Thanks!

React Native SwiftUI 'unrecognized selector sent to instance'

$
0
0

I'm trying to use a SwiftUI component with my React Native app, which appears to be a little complicated since I haven't found any documentation or tutorials for doing this online. Here are the files I'm using:

CategoryCardView.swift

import UIKit
import SwiftUI

struct CategoryCard: View {
  var name: String
  var body: some View {
      Text(name)
  }
}

@objc(RCTCategoryCardViewManager)
class RCTCategoryCardViewManager: RCTViewManager {
  override static func requiresMainQueueSetup() -> Bool {
    return true
  }

  @objc var name: String = "Default text"
  override func view() -> UIView! {
    let swiftUIView = CategoryCard(name: name)
    let viewController = UIHostingController(rootView: swiftUIView)
    return viewController.view
  }
}

CategoryCardView.m

#import <React/RCTViewManager.h>

@interface RCT_EXTERN_MODULE(RCTCategoryCardViewManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(name, NSString)
@end

NativeCategoryCard.tsx (in React Native):

import {requireNativeComponent} from "react-native";
import React from "react";

const NativeCategoryCard = requireNativeComponent('RCTCategoryCardView');

export interface CategoryCardProps{
    name: string;
}

function CategoryCard(props: CategoryCardProps) {
    return <NativeCategoryCard
        style={[{
            height: 100,
            width: 100
        }]}
        {...props}
    />
}

export default CategoryCard;

And then somewhere in my React Native code:

<CategoryCard text='hello' />

My app throws the following error when it tries rendering <CategoryCard>:

Exception thrown while executing UI block: -[_TtGC7SwiftUI14_UIHostingViewV7PalChat12CategoryCard_ setName:]: unrecognized selector sent to instance 0x7fc8718c7830

I don't really understand Swift and SwiftUI thoroughly, especially in terms of integrating it with React Native, so I apologise if I'm making an obvious mistake.


Tool to emulate Interface Builder with React Native iOS app with Windows 10

$
0
0

I'm trying React Native developing iOS and Android apps as I think it could be a viable alternative to Native. I really like the concept but I don't currently have Mac. Is there a tool available that would enable me to run my React code in an emulator or build my UI as in Interface builder without the benefit of Xcode?

I've heard there is a tool called Flexbox but would it do both jobs and if not is there anything else or do I need to retrieve my Mac?

How to efficiently trace the source of error in React Native?

$
0
0

I'm getting the following error and I'm beyond frustrated. Expo doesn't point towards the source of the error for some reason and I've been combing through all of my codes for the past half an hour to find this mysterious variable, "st". I'm assuming this is some typo that I've made. I've commented out all of my screens, but still the same error. So I've combed through all of the query and mutation files, App.js, etc, but still no luck. I've even combed through the back end files to no avail. I've removed and re-installed my node modules, but still the same error. Is there a way to trace the source of this more efficiently? Or is this even a typo error or is this something else? Please help!!

enter image description here

I get the following instruction:

info PRO TIP When you see Red Box with stack trace, you can click any stack frame to jump to the source file. The packager will launch your editor of choice. It will first look at REACT_EDITOR environment variable, then at EDITOR. To set it up, you can add something like export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on which shell you use.

so I set up my vcode in bashrc as the REACT_EDITOR but clicking on the error doesn't launch the editor to the source file.

How do we handle navigation when integrating react-native to an existing native project

$
0
0

I am trying to integrate a react-native project to existing native projects(android and iOS). What are the different options available for acheiving full navigation from native to JS and vice-versa with a single navigation control.

  1. Say i want to add just a single .reactNativeActivity and render all of my ReactNative activity in it. Now this react-native activity has its own navigation(say react-navigation), i should be able to navigate to native activity. I have done this creating native modules. This is solved.
  2. Now how can i navigate from an native activity to this .reactNativeActivity to a particular screen inside it.

I see that we had native-navigation library by airbnb which isn't being supported now. I can still add all the react native screens as individual activities which will still solve this but i don't see that it can be maintainable. Can somebody guide as to how to proceed with this and how do others generally do?

Allow user to change App Icon in React Native

$
0
0

Apple specifies that users can change their icon to give a more personalised experience. See docs here:

https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/app-icon/#user-selectable-app-icons

My question is regarding using this functionality in React Native. Building an app in React Native is it possible to access this setAlternateIconName method and provide the user with alternate app icons? Does React Native provide a nice way to interact with this IOS method?

What does @format mean in new react native App.js?

$
0
0

I started to create an Application in react native so, i setup the react native environment and found the @format in the App.js file when i open this file first time. Please can anyone tell what is @format and why it is in the new App.js file in react native?

Viewing all 16552 articles
Browse latest View live


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