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

React Native iOS build issues while installing react-native-vector-icons

$
0
0

I am learning React Native and am at my wits end on this issue on my very first project. I am trying to install react-native-vector-icons and while everything works perfectly in Android, iOS wont run.

Here are the errors I get (happy to provide any other details that will help, but please remember I am new and may need you to walk me through what to type in to get it):

  1. In XCode i see this when I build: Apple Mach-O Linker Error; Library not found for -lCocoaAsyncSocket; Linker command failed with exit code 1 (use -v to see invocation)
  2. In terminal I see: 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 <appName>.xcworkspace

I have tried the following based on my web research:

  1. pod deintegrate && pod install (I also updated pod to the latest)
  2. I walked through all of the steps to install on the github site and even started up a second fresh project and walked through a youtube tutorial with the same results.
  3. I have cleaned the cache, deleted the build folder and tried to rebuild, deleted the podfile.lock folder and resinstalled, rebooted my machine entirely, ensured that i am opening the .xcworkspace file and not the .xcodeproj file, i have changed my build system workspace settings to legacy, i have linked and unlinked a dozen times.

Other data that might be useful:

  1. Here are my react versions: react-native-cli: 2.0.1react-native: 0.63.2
  2. This happened when I tried to install react-native-maps but it somehow miraculously "fixed itself' after running the run-ios command for the 20th time.
  3. I am not sure that autolinking is working as I have to run react-native link <package> --platforms ios whenever i install a 3P package.

I would appreciate any help that can be provided and am happy to add in any detail needed (just please help me with how to get it).

Thanks in advance for any help you can provide!


Why my design gets disappear when I use ?

$
0
0
<View style={{flex:1}} ><ImageBackground          source={require('../images/back02.png')}          style={styles.bgscreen}          onPress={Keyboard.dismiss}><KeyboardAvoidingView behavior='position'><Image          style={styles.headImage}          source={require('../images/login_img.png')} /><ImgBack navigation={this.props.navigation} /></KeyboardAvoidingView></ImageBackground></View></TouchableWithoutFeedback>

If i remove <TouchableWithoutFeedback> then everything is fine. Help me. Don't ask for Child Component code. No need to know about that. Everthing is fine there.

I am just having problem with the <TouchableWithoutFeedback>

I have imported import { TouchableWithoutFeedback } from 'react-native-gesture-handler';

How to make the menu in react-native picture? iOS

$
0
0

Yes, I am new among you, I want to make the application I made with react-native for ios the menu in the picture below. How can I do?i made

want to do

React-Native-Sound path for ios file?

$
0
0

I'm curently developping an app on React-Native and I need to play sound.The fact is that I am on Ubuntu and developing with IntelIJ Idea.

I'm using react-native-sound library to play sounds.

Thanks to this post, I know where I put my .mp3 file for android, but the files have to be somewhere in the ios section as well ?

Where do we put them ?

How to fit content of a Stack Navigator inside View?

$
0
0
const TabNavigator = () => (<Stack.Navigator screenOptions={{headerShown: false}}><Stack.Screen name="Order" component={OrderScreen} /><Stack.Screen name="Shops" component={ShopScreen} /><Stack.Screen name="Categories" component={CategoryScreen} /><Stack.Screen name="Profile" component={ProfileScreen} /></Stack.Navigator>);const MainScreen = ({navigation}) => {  return (<ScrollView style={styles.rootContainer}><StatusBar backgroundColor="#fff" barStyle="dark-content" /><View style={styles.navigationContainer}><View style={styles.topIconContainer}><Image            source={{uri: 'https://picsum.photos/id/237/200/300'}}            style={styles.topIcons}          /><Image            source={{uri: 'https://picsum.photos/id/1005/200/300'}}            style={styles.topIcons}          /></View><Text          style={{            fontSize: 35,            width: Dimensions.get('screen').width / 2,            fontWeight: 'bold',            marginBottom: 20,          }}>          Grocery Delivery</Text><View style={styles.navigator}><TouchableOpacity            style={styles.navigatorButtons}            onPress={() => {              navigation.navigate('Order');            }}><Text>Order</Text><View style={styles.navigatorIndicators} /></TouchableOpacity><TouchableOpacity            style={styles.navigatorButtons}            onPress={() => {              navigation.navigate('Shops');            }}><Text>Shops</Text><View style={styles.navigatorIndicators} /></TouchableOpacity><TouchableOpacity            style={styles.navigatorButtons}            onPress={() => {              navigation.navigate('Categories');            }}><Text>Category</Text><View style={styles.navigatorIndicators} /></TouchableOpacity></View></View>      {/* MY PROBLEM */}<View style={{height: 500}}><TabNavigator /></View></ScrollView>  );};

My Problem:By default, the height of the View (under the comment I put the code) is zero.

Expected:The View should have a min-height of the TabNavigator so that it does not clip its content.

I want the View (the last child inside the main parent) to adjust itself to the height of TabNavigator

Firebase: How to get email from sign in with apple on real device?

$
0
0

I'm implementing a sign in with apple, this is my code on apple button press

  onAppleButtonPress = async () => {// performs login requestconst appleAuthRequestResponse = await appleAuth.performRequest({  requestedOperation: AppleAuthRequestOperation.LOGIN,  requestedScopes: [    AppleAuthRequestScope.EMAIL,    AppleAuthRequestScope.FULL_NAME,  ],});// Ensure Apple returned a user identityTokenif (!appleAuthRequestResponse.identityToken) {  console.log('no token');  throw 'Apple Sign-In failed - no identify token returned';}// Create a Firebase credential from the responseconst {identityToken, nonce} = appleAuthRequestResponse;const appleCredential = firebaseAuth.AppleAuthProvider.credential(  identityToken,  nonce,);//I WANT TO GET THE EMAIL HERE TO USE CHECK IT FROM FIREBASE IF EMAIL ALREADY EXISTS BY THIS CODEfirebaseAuth()        .fetchSignInMethodsForEmail(appleAuthRequestResponse.email)        .then(providers => {});}

It works on the simulator, but on real device the email is null.Anyone who can help?

Embedding a React Native component inside a native app removes other components

$
0
0

Anyone had success with embedding a React Native component inside a native app, where you have the RN component only filling part of the screen in the native app? I need my RN component to show up when tapping a particular button in a UITabBar and then take up the space available above the UITabBar.

When add a subview embedding the RN component, all other components of the view it is added to disappear from the UI?!

Image: How it should work

Image: What actually happens

In the official RN docs at https://reactnative.dev/docs/integration-with-existing-apps it's only shown how to show an entirely new page where the old native UI is no longer shown. Found this page https://www.decoide.org/react-native/docs/embedded-app-ios.html which shows the RN component taking up partial space on the screen. But no native controls are shown along side it in the sample. I tried to copy this sample and adding some other components in the xcode storyboard, but to no avail. They all disappeared when the RN component gets shown, even though it has been specified that it should stay in an area of (20,20,200,200).

Spent a lot of time searching the Internet, but not sure how many people are actually doing what I try to do here. Hope someone can help!

Here's a snippet of code used in my ViewController:

    - (void)viewDidLoad {[super viewDidLoad];      NSURL *jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];      RCTRootView *rootView =      [[RCTRootView alloc] initWithBundleURL: jsCodeLocation                             moduleName: @"SimpleApp"                             launchOptions: nil];      [self.view addSubview:rootView];      rootView.frame = CGRectMake(20, 20, 200, 200);    }

Background "connection to car" detection - React Native

$
0
0

I have a react native app. I want to pop-up a notification to user when he is in the car.I could use react-native-activity-recognition package, but the problem is, that it will notify only when the user already started the driving. I need it to happen before.

Therefore, I believe my solution is in BT detection or some other "hands-free" mode state. I found this package: react-native-car-connect. The problem is that it doesn't seem to support android at this point.

Then I thought maybe use this package: react-native-headphone-detection, from what I understood it works only in foreground, also I don't want to popup the notifications for every BT connection, but for the car.

Is it even possible what I am looking for? If it does, maybe I should look into another direction?

Thanks


Programmatically Restart a React Native App

$
0
0

Is it possible to programmatically restart a React Native app without writing any native code?

For instance, I know from the answer to this question that I can restart an Android app with:

Intent i = getBaseContext().getPackageManager()         .getLaunchIntentForPackage( getBaseContext().getPackageName() );i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);startActivity(i);

Can I do the same with React Native?

React Native: How can I detect if my code is running in the Simulator?

$
0
0

In a Obj-C iOS app I can use #if (TARGET_IPHONE_SIMULATOR) to write simulator-only code.

In react native I can use:

if (__DEV__) { .. do something special}

.. to detect development mode.

We can use Platform.OS === 'ios' to detect the platform (Android/iOS).See here for more info Platform Docs

But how do we detect if the app is running in the simulator?

The reason I ask is that my app uses the camera to scan barcodes, and this isn't supported in the iOS Simulator.

Set user agent with WebView with react-native

$
0
0

I want to modify the user agent string in a WebView so that on the server side I can detect that the request has come from my react-native app. I want to do this using the source prop in the WebView.

How do I do this for IOS and Android?

Error running expo build:ios on Windows Computer for React Native App

$
0
0

I am attempting to build an IOS version of my React Native App using Expo CLI, but I get the following error:

error

Has anyone encountered this issue before? The Android version of my app built fine and my app runs smoothly, so I am having trouble interpreting why this issue is occurring. I should also note that I am enrolled in Apple's Developer Program, so I don't think that's the issue. Any advice would be much appreciated.

Fixing Error 403 while allowing FCM Push notifications

$
0
0

I am working on a React Native webview app for a Ruby on Rails website. I added Push Notifications using Firebase Cloud Messaging. My colleague integrated the Google Calendar API into the RoR website, and it works fine when on the website. But, when trying to sign in to google in the webview app, I'm getting this error.

I tried putting the objective c code of this solution into my AppDelegate.m, and it prompted me to enter my gmail, but then gave this different error.

I then tried putting the objective c code of this solution into my AppDelegate.m, and it allowed me to sign into google properly. However, it broke my Firebase Push Notifications, so that now it will not ask the user for push notification permission.

Has anyone had a similar issue and know of a solution or ideas? Is there a good solution that allows a webview app to sign into google and use firebase push notifications?

Can we pass path to bottomsheet instead of screen from react native to native

$
0
0

Scenario:

I am having one bottomsheet in react native I have to show on the native. Is there any solution to pass react native path to native directly to the bottomsheet instead of screen.

Problem:

Now I am passing path to screen but the problem is here is on the empty screen the bottom sheet is coming.

creating release-app for ios in react-native in normal system

$
0
0

I'm owning linux system so is it possible to create release-apk for ios devices.

as when can create apk via using build command i.e (.gradlew bundleRelease)


RN- IOS directory not found for option AppAuth

$
0
0

I'm running "React-native run-ios" or running via xCode and getting this error, what's the problem? Thank you.

Note: I am using project.xcworkspace.

XCode error output;

ld: warning: directory not found for option '-L-L/Users/XXXX/Library/Developer/Xcode/DerivedData/XXXX-xxxxxxxxxxxx/Build/Products/Debug-iphonesimulator/AppAuth' ld: library not found for -lAppAuth clang: error: linker command failed with exit code 1 (use -v to see invocation)

package.json

> "dependencies": {>     "@react-native-community/async-storage": "^1.11.0",>     "@react-native-community/google-signin": "^4.0.3",>     "@react-native-community/masked-view": "^0.1.10",>     "@react-native-community/netinfo": "^5.9.5",>     "@react-native-community/toolbar-android": "0.1.0-rc.2",>     "@react-navigation/native": "^5.5.1",>     "@react-navigation/stack": "^5.5.1",>     "amazon-cognito-identity-js": "^4.3.3",>     "aws-amplify": "^3.0.22",>     "aws-amplify-react-native": "^4.2.3",>     "axios": "^0.19.2",>     "lodash": "^4.17.15",>     "lottie-react-native": "^3.5.0",>     "moment": "^2.27.0",>     "react": "16.13.1",>     "react-native": "0.63.1",>     "react-native-aws-signature": "0.0.9",>     "react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",>     "react-native-easy-toast": "^1.2.0",>     "react-native-fbsdk": "^2.0.0",>     "react-native-flags": "^1.0.0",>     "react-native-gesture-handler": "^1.6.1",>     "react-native-i18n": "^2.0.15",>     "react-native-permissions": "^2.1.5",>     "react-native-qrcode-scanner": "^1.4.1",>     "react-native-reanimated": "^1.9.0",>     "react-native-safe-area-context": "^3.0.3",>     "react-native-screens": "^2.8.0",>     "react-native-vector-icons": "^6.7.0",>     "react-native-vega-scroll-list": "^1.0.0",>     "react-redux": "^7.2.0",>     "redux": "^4.0.5",>     "redux-devtools-extension": "^2.13.8",>     "redux-logger": "^3.0.6",>     "redux-persist": "^6.0.0",>     "redux-promise-middleware": "^6.1.2",>     "redux-thunk": "^2.3.0",>     "remote-redux-devtools": "^0.5.16"  > },

How to change React Native cursor color?

$
0
0

I am using React Native and I would like to change the cursor color of a text input. I actually got the default blue color.

How can I set a global color either in JavaScript or in AppDelegate ?

Trying to load react native component inside android exiting layout file

$
0
0

I'm facing one issue on android and react native changes of. The scenario is, in react native I have called api to update state of data and show the following view if data return empty array then hide view. The problem is if I check empty array condition then it works fine on react native pages of react component but using same senario react native component is not visible on android layout. But if I remove condition check then it is working on both android and react native pages.

I have observe this on any react native component is, Whenever we open on any react component the render method is called twice or thrice time. For first time it takes the initial value of state declare in constructor and render on both android and react native pages then we make state update in componentDidMount then again the render method is called but this time updated state component is appering on react native page but not on android layout. I belive that's what happening here it takes initial value and render on native pages but when state got updated then it is not re-rendering in android layout but it is working on react native pages.

So, if you guys have any idea or solution for this please let me know and feel free to ask any question related to this.

/*Attach this fragment in activity where you want to show this fragmentAdd this in activity:        FragmentManager fragmentManager = getSupportFragmentManager();        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();        Fragment fragment = StripFragment.newInstance("Q&A", "1");        fragmentTransaction.add(R.id.includeLayout, fragment);        fragmentTransaction.commit();Add this in activity xml file:<include layout="@layout/fragmentStrip"                         android:id="@+id/includeLayout"                         android:layout_width="match_parent"                         android:layout_height="wrap_content"/>*/public class StripFragment extends Fragment implements DefaultHardwareBackBtnHandler, ReactInstanceManager.ReactInstanceEventListener {    private static final String TAG = "StripFragment";    private static final String STRIP_MODULE_NAME = "moduleName";    private static final String STRIP_MODULE_TYPE = "moduleType";    public final String PAGE_TYPE = "PAGE_TYPE";    public final String PROPS_PARAM = "propsParam";    private ReactInstanceManager mReactInstanceManager;    private Context mContext;    private ReactContext mReactContext;    private ReactRootView mReactRootView;    private FrameLayout parent;    public static StripFragment newInstance(String moduleName, String moduleType) {        StripFragment fragment = new StripFragment();        Bundle args = new Bundle();        args.putString(STRIP_MODULE_NAME, moduleName);        args.putString(STRIP_MODULE_TYPE, moduleType);        fragment.setArguments(args);        return fragment;    }    @Override    public void onAttach(@NonNull Context context) {        super.onAttach(context);        mContext = context;    }    @Override    public void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        mReactInstanceManager = ReactInstanceSingleton.getReactInstanceManager(Objects.requireNonNull(getActivity()).getApplication());        if (mReactContext == null) {            mReactContext = mReactInstanceManager.getCurrentReactContext();        }    }    @Override    public View onCreateView(LayoutInflater inflater, ViewGroup container,                             Bundle savedInstanceState) {        final View view = inflater.inflate(R.layout.fragmentStrip, container, false);        parent = view.findViewById(R.id.stripFrameLayout);        return view;    }    @Override    public void onActivityCreated(Bundle savedInstanceState) {        super.onActivityCreated(savedInstanceState);        String moduleName = null;        String moduleType = null;        JSONObject header_obj = new JSONObject();        JSONObject obj = new JSONObject();        if (getArguments() != null) {            moduleName = getArguments().getString(STRIP_MODULE_NAME, null);            moduleType = getArguments().getString(STRIP_MODULE_TYPE, null);        }        try {            if (moduleName != null && moduleType != null) {                obj.put("moduleName", moduleName);                obj.put("moduleType", moduleType);            }        } catch (JSONException e) {            e.printStackTrace();        }        final Bundle bundle = new Bundle();        bundle.putString(PAGE_TYPE, "MyStripFragment");        bundle.putString(PROPS_PARAM, obj.toString());        mReactRootView = new ReactRootView(Objects.requireNonNull(getActivity()).getApplicationContext());        parent.addView(mReactRootView);        new Handler().postDelayed(new Runnable() {            @Override            public void run() {                try {                    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mReactRootView.getLayoutParams();                    layoutParams.height = parent.getMeasuredHeight();                    layoutParams.width = parent.getMeasuredWidth();                    mReactRootView.setLayoutParams(layoutParams);                    parent.invalidate();                    mReactRootView.invalidate();                } catch (Exception e) {                    e.printStackTrace();                }            }        }, 500);        try {            mReactRootView.startReactApplication(                    mReactInstanceManager,"MyApplication",                    bundle            );        } catch (Exception e) {            e.printStackTrace();        }    }    @Override    public void onReactContextInitialized(ReactContext context) {        mReactContext = context;    }    @Override    public void invokeDefaultOnBackPressed() {}    @Override    public void onDestroy() {        super.onDestroy();        try {            if (mReactInstanceManager != null) {                mReactInstanceManager = null;            }            if (mReactRootView != null) {                mReactRootView.unmountReactApplication();                mReactRootView = null;            }            if (mReactContext != null) {                mReactContext = null;            }            if (parent != null) {                parent.removeAllViews();                parent = null;            }        } catch (Exception e) {            e.printStackTrace();        }    }}

// XML layout file fragmentStrip.xml

<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/stripFrameLayout"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_marginHorizontal="@dimen/dimen8dp"    tools:context=".app.Application.StripFragment"></FrameLayout>

//React native router.js file

_setStripPropsData = () => {    let objStr = JSON.parse(this.props.propsParam);    let moduleType = objStr.moduleType ? objStr.moduleType : null;    let moduleName = objStr.moduleName ? objStr.moduleName : null;    return <MyComponent moduleType={moduleType} moduleName={moduleName} />;  };if (this.props.PAGE_TYPE == "MyStripFragment") {      return this._setStripPropsData();    }

// MyComponent.js file

export default class MyComponent extends React.PureComponent {constructor(props) {    super(props);    this.state = {      data: [],    };}// I'm updating data with api call and api is working finerender(){<View><Text>Text1</Text>{this.state.data != undefined &&this.state.data.length > 0 ?(<Text>Text2</Text><FlatList     horizontal={true}     data={this.state.data}     renderItem={this.renderItem}     keyExtractor={(item, index) => index.toString()}     />): null}</View>}}

How do I send React Application context from non react class?

$
0
0

I need to update status changes like event between android and react native class?

public class MessagingService extends FirebaseMessagingService {      @Override      public void onMessageReceived(RemoteMessage remoteMessage) {        Log.d(TAG, "Push Message Received ");        buildLocalNotification(remoteMessage);      }      public void buildLocalNotification(RemoteMessage message) {        ...        FBMessagingHelper notificationHelper = new FBMessagingHelper(this.getApplication());        notificationHelper.showNotification(bundle);      }    }

How can I create a ReactApplicationContext constructor as class is extended to FBMessingService?

FBMessagingHelper notificationHelper = new FBMessagingHelper(this.getApplication());// Getting Error as a parameter is not react app context

I need to update IN_VIDEO_PROGRESS status

  1. Update to Android when video starts/stop by React Native.
  2. Update to React Native when video starts/stop by Android.
public class FBMessagingHelper extends ReactContextBaseJavaModule {  private ReactApplicationContext mContext;  private static boolean IN_VIDEO_PROGRESS = false;  public FBMessagingHelper(ReactApplicationContext reactContext) { // Added into Native Modules     mContext = applicationContext;  }@ReactMethod    public void onVideoProgress(Bolean status){        // ==== on videoProgress ====        IN_VIDEO_PROGRESS = status    } @Nonnull @Override    public String getName() {        return "FBMessagingHelper";    }  public void showCustomNotification(Bundle bundle) {    if (!IN_VIDEO_PROGRESS && bundle.getString("category").equals("VIDEO") {       IN_VIDEO_PROGRESS = true;       // start FullScreenNotificationActivity    }  }}

Created Native Modules:

    public class FBMessagingPackage implements ReactPackage{    @Override      public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {        List<NativeModule> modules = new ArrayList<>();        modules.add(new FBMessagingHelper(reactContext));        modules.add((NativeModule) new MessagingService(reactContext));        // Error: cannot be cast to nativeModule        return modules;      }        ...        ...    }

Deep Link is not handled when app is closed React Native iOS app

$
0
0

I'm developing a React Native app for iOS.

This app has to be able to open deeplinks and it works fine when the app is opened in background.When the app is close, the native iOS code (Objective-C) does not get the URL the app has been opened with.

As I understand how it works, I have to check the NSDictionary of the launchOptions to see if the app has been started through an URL. If the key corresponding to URL initialization exists then I return true to execute the following code

- (BOOL)application:(UIApplication *)application        openURL:(NSURL *)url        options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {  return [RCTLinkingManager application:application openURL:url options:options];  return YES;}

This is the function that has to bee executed to get the Initial Url which the app has been opened with. Here is my code of app didFinishWithLaunchOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary  *)launchOptions{    if ([launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]) {    return true;  }}
Viewing all 17108 articles
Browse latest View live


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