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

I want to verify react native apple authentication in php server-side [closed]


Open default ios contact list in react native app with multiple contacts select

$
0
0

I want to open default ios contacts list with multiple contact selection in react native. For that I tried react-native-contacts-wrapper package, it doesn't support multi-contact select. So I moved to react-native-contacts, which allows multiple contact select, but it doesn't give the look and feel of ios contact list.

Is there any package which has multiple contact select with default ios contact list UI?

How to build my react native app with TeamCity?

$
0
0

I start using Team City and my app builds with react nativeversion 0.60.5...

I was wondering what will be the best and the easier way to build my app for iOS and android. For iOS I was thinking using the Xcode plug.

For android I'm thinking to use Docker but its complicated and taking time to develop..

Does someone has any recommendation what to use for building my android app or Docker is a good solution?

And about the iOS, are you recommend use the Xcode plug or any other idea?

Thank you for the help

getExpoPushTokenAsync return null in IOS device

$
0
0

I'm working on a push notifications system with Expo. I tried to get token and save it to mobile storage:

/**
   * Demande d'autorisation pour accéder au token du GSM et l'envoyer vers l'api
  */
  registerForPush = async () => {
    if (Constants.isDevice) {
      const { status: existingStatus } = await Permissions.getAsync(
        Permissions.NOTIFICATIONS,
      );
      let finalStatus = existingStatus;
      if (existingStatus !== 'granted') {
        const { status } = await Permissions.askAsync(
          Permissions.NOTIFICATIONS,
        );
        finalStatus = status;
      }
      if (finalStatus !== 'granted') {
        alert('Failed to get push token for push notification!');
        return;
      }
      const gsm = await Notifications.getExpoPushTokenAsync();
      this._storeData('TOKEN_GSM', gsm);
    } else {
      alert('Must use physical device for Push Notifications');
    }
  };

Component Did Mount :

async componentDidMount() {
    console.log("##########  COMPONENT DID MOUNT   ############");
    this.registerForPush();

I got the token in android mobile but in IOS i got null value.

i can't run pod install with react native

$
0
0

I have created a mobile app with react-native but when I run pod install in ios directory, getting the following error.

[!] Invalid `Podfile` file: A JSON text must at least contain two octets!.



#  from /Users/softcity/AppTest/ios/Podfile:42
 #  -------------------------------------------
 #    end
 >  use_native_modules!
 #  end
 #  -------------------------------------------
SoftCitys-MacBook-Air:ios softcity$ 

Here is the code of Podfile:

 platform :ios, '9.0'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'    
    target 'AppTest' do
      # Pods for AppTest
      pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
      pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
      pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
      pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
      pod 'React', :path => '../node_modules/react-native/'
      pod 'React-Core', :path => '../node_modules/react-native/'
      pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
      pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
      pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
      pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
      pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
      pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
      pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
      pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
      pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
      pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
      pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
      pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

      pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
      pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
      pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
      pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
      pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
      pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
      pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

      pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
      pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
      pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

      target 'AppTestTests' do
        inherit! :search_paths
        # Pods for testing
      end
    use_native_modules!
    end

    target 'AppTest-tvOS' do
      # Pods for AppTest-tvOS

      target 'AppTest-tvOSTests' do
        inherit! :search_paths
        # Pods for testing
      end

    end

Please help me !!

Disable Screen Capture/ScreenShot in React Native App

$
0
0

I have came across few solutions specific for ios and Android to prevent screen-capturing and taking screenshots. But how do i disable screen-capturing in react native?

Expo React Native extra space at the top and bottom of the app on iPhone 11

$
0
0

I have a problem where there is extra space above the at the top and below the tab navigation at the bottom of the app when running it on an iPhone 11. I don't see them on earlier device versions. Does anybody have any pointers on how to get rid of the space? (The bits in the red boxes in the image below)

iphone react native app with extra space top and bottom

I'm using Expo SDK 36.0.0 and React Native 0.61.5.

Thanks!

=======

Switch component not animating when value changes programmatically

$
0
0

When I update the value of the Switch component via state, the toggle transition doesnt work. It goes instantly from on to off and vice versa. However, when I directly click on the switch, it animates just fine.

Is there any way to animate the transition when I switch the value via state? This is what my switch looks like:

<Switch value={this.props.switchIsEnabled}></Switch>

React native FCM iOS push notification not delivered

$
0
0

first of all environment is React native, I try to setup push notification in iOS following instruction from rnfirebase package here what step i do and I do testing on Real iPhone Device

  1. create key

enter image description here

  1. then add to firebase

enter image description here

  1. add Google-service.plist and add setup following from firebase doc

enter image description here

and acivate capabillity enter image description here

  1. then I install pod package

enter image description here

  1. run app got token

enter image description here

  1. use token send on cloud messaging console

notification not delivered I didn't know what wrong because message also send from FCM and what happens on APNS where I get an error just confused

thank for advance

and also try by connecting directly with pusher enter image description here

and also not received again

then try to use Onesignal with same certificate with Firebase is work even on the test message

react-native-text-detector worked fine in android but why it always returned false in iOS?

$
0
0

First, I used https://github.com/jeanpan/react-native-camera-roll-picker#readme to get an image from photo library, it returned a uri: ph://11A68DD6-A651-462D-BDAB-68FB853ED141/L0/001

Then, I used https://github.com/zsajjad/react-native-text-detector to get text from that image

It worked fine in android but it always returned false in iOS, and I found the following error in console log

NSURLConnection finished with error - code -1002

For more information, the image control can show that image correctly

Here is my source code : https://github.com/haison8x/react-native-test-ocr

Is there any problem with that URI or with application permission?

React Native: Cache Image, Video, all type of documents (.pdf, .xls, ..) in iOS

$
0
0

I have a scenario to cache all types of user files (Image, Video, all word documents, pdf, etc) in react native application. Currently, I am using react-native-fast-image for image cache which is actually working the best.

But I need any popular library/approach which can handle all types of mentioned files.

Currently, I am using FastImage component as given below

<FastImage source={{uri: source}}
        resizeMode={FastImage.resizeMode.cover}
        style={{...style}}
        onLoad={(e) => {
          this.setState({imageLoaded: true})
        }}
      />

programmatically retrieve Header component height - React Native

$
0
0

Using NativeBase, I added a Header component. Now, I want to programmatically retrieve the height of the header. How can I do this. The code for adding the Header is given below:

I tried using Dimensions.get('window') but it gives me the height of the entire view.

The code:

import React, {Component} from 'react-native';
import {Container, Header, Button, Title, Icon} from 'native-base';
​
export default class ThemeHeaderExample extends Component {
    render() {
        return (
                <Header>
                    <Button transparent />

                    <Title>Header</Title>

                </Header>
        );
    }
}

seekTo function restarts the track on android instead of seeking to required position, react-native-track-player

$
0
0

i am making an audio player in react native in which i have to implement 15 sec forward and 15 sec backward buttons , in iOS it's working fine and both the buttons are working correctly, in android when i press 15 sec forward button it restarts the track as well as the seek bar instead of seeking to 15 seconds forward. my react-native version : 0.61.5 the package i am using: react-native-track-player, version: 1.1.8

FlatList onEndReached being called multiple times

$
0
0

I'm making a react native project where user can search images using Flickr API, Everything else is working fine but the problem i'm having while implementing pagination. I have used FlatList's onEndReached to detect when user has scrolled to the end on the list, but the problem is onEndReached is being called multiple times(including one during the first render). I have even disabled bounce as said here but it's still being called more than once

 export default class BrowserHome extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: false,
      tagParam: "cat",
      pageNum: -1,
      data: [],
      photosObj: ""
    };
  }

  componentDidMount() {
    this.setState({
      isLoading: true
    });
    try {
      this.makeRequest();
    } catch {
      console.log("error has occurred");
    }
  }

  makeRequest = () => {
    const { tagParam, pageNum } = this.state;
    let url = `https://api.flickr.com/services/rest/? 
               method=flickr.photos.search
               &api_key=${apiKey}&format=json&tags=${tagParam}
               &per_page=30&page=${pageNum + 1}&nojsoncallback=1`;
    fetch(url, {
      method: "GET"
    })
      .then(response => response.json())
      .then(responseJSON => {
        this.setState({
          data: this.state.data.concat(responseJSON.photos.photo),
          isLoading: false,
          pageNum: responseJSON.photos.page
        });
      })
      .catch(error => {
        console.log(error);
        this.setState({ isLoading: false });
        throw error;
      });
  };

  render() {
    if (this.state.isLoading) {
      return <ActivityIndicator animating={true} size="large" />;
    }

    return (
      <View
        style={{
          flex: 1,
          height: 200,
          justifyContent: "flex-start",
          width: screenSize.width,
          backgroundColor: "black"
        }}
      >
        <Text>This is browserhome</Text>
        <FlatList
          style={{
            width: screenSize.width
          }}
          numColumns={3}
          data={this.state.data}
          keyExtractor={item => item.id}
          bounces={false}
          onEndReachedThreshold={1}
          onEndReached={({ distanceFromEnd }) => {
            this.loadMoreItem();
            alert("end reached call");
          }}
          renderItem={({ item, index }) => (
            <>
              <ImageTile imageURL={this.createImageURL(item)} />
            //  <Text style={{ color: "white" }}>
             //   {index}
             //   {console.log(index)}
             // </Text>
            </>
          )}
        />
      </View>
    );
  }

  createImageURL(item) {
    let server = item.server,
      id = item.id,
      secret = item.secret;
    let urlString = `https://farm${
      item.farm
    }.staticflickr.com/${server}/${id}_${secret}_s.jpg`;
    return urlString;
  }

  loadMoreItem() {
    this.makeRequest();
  }
}

React native ios deep linking with push notifications

$
0
0

I have a RN app, and i have an sdk which is responsible for push notifications and deep linking. I want my app to be able to open at certain paths inside the app and also open appstore so that users can download the earliest version of app, through push notifications. I have already set the url schemes.

<array>
        <dict>
            <key>CFBundleURLName</key>
            <string>xxx</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>xxx</string>
            </array>
        </dict>
    </array>

In my appDelegate i have this function

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

The problem is that when I click on the push notification, app opens something like an internal browser, it loads for some time and then it stays there with a white screen and some buttons on the bottom. Everything I read and tried from the web is not working. Can anyone help me with my code?

PS. Debugger does not even pass by the function I wrote above. It does only if I paste my deep link url in safari and then it works correctly.


Include of non-modular header inside framework module 'UMReactNativeAdapter... after adding react-native-unimodules

$
0
0

I get the following error after adding react-native-unimodules when running react-native run-ios. I tried building the project on Xcode as well, but I still get errors. I followed the react-native-unimodules install configuration. On android project works fine.

any help is welcome!

error: include of non-modular header inside framework module 'UMReactNativeAdapter.UMViewManagerAdapterClassesRegistry': '/Users/danie
info lmorbeck/Documents/Start-you-up/app-multas-br/ios/build/multasbr/Build/Products/Debug-iphonesimulator/include/React/RCTViewManager.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import <React/RCTViewManager.h>
        ^
While building module 'UMReactNativeAdapter' imported from /Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/multasbr/AppDelegate.h:9:
In file included from <module-includes>:1:
In file included from /Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/build/multasbr/Build/Products/Debug-iphonesimulator/UMReactNativeAdapter/UMReactNativeAdapter.framework/Headers/UMReactNativeAdapter-umbrella.h:21:
/Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/build/multasbr/Build/Products/Debug-iphonesimulator/UMReactNativeAdapter/UMReactNativeAdapter.framework/Headers/UMViewManagerAdapter.h:3:9: error: include of non-modular header inside framework module 'UMReactNativeAdapter.UMViewManagerAdapter': '/Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/build/multasbr/Build/Products/Debug-iphonesimulator/include/React/RCTViewManager.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import <React/RCTViewManager.h>
        ^
6 errors generated.
In file included from /Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/multasbr/main.m:10:
/Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/multasbr/AppDelegate.h:9:9: fatal error: could not build module 'UMReactNativeAdapter'
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
 ~~~~~~~^
7 errors generated.


error 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 multasbr.xcworkspace

** BUILD FAILED **


The following build commands failed:
    CompileC /Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/build/multasbr/Build/Intermediates.noindex/multasbr.build/Debug-iphonesimulator/multasbr.build/Objects-normal/x86_64/main.o /Users/danielmorbeck/Documents/Start-you-up/app-multas-br/ios/multasbr/main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler

this is my Podfile

platform :ios, '10.0'

require_relative '../node_modules/react-native-unimodules/cocoapods.rb'

target 'multasbr' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for multasbr
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTAnimation',
    'RCTImage',
  ]

  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  use_unimodules!

  target 'multasbr-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'multasbrTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'multasbr-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for multasbr-tvOS

end

my AppDelegate.h

#import <React/RCTBridgeDelegate.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@property (nonatomic, strong) UIWindow *window;

@end

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"multasbr"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

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

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
  // You can inject any extra modules that you would like here, more information at:
  // https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
  return extraModules;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

React-native, iOS simulator stops responding to CMD + D

$
0
0

since a couple of months I'm facing a very strange situation, when developing on the latest versions of react native (0.50+ to 0.60+) the iOS simulator stops responding to keyboard commands, that is:

  • Simulator starts, I can hit Cmd+R or Cmd+D just fine for a few cycles
  • After some hot reload cycles, the commands completely stop working
  • If go to Hardware->Keyboard->Send Keyboard Shortcuts and enabled it, the commands start working again
  • However then the Cmd+Shift+H doesn't work anymore so I cannot easily close the app if I have to

This is really driving me crazy, has anybody faced the same situation or knows any workaround? Many thanks!

P.S. I already tried a few months ago to reset everything (including simulator settings and xcode installation)

Google SignIn for IOS with React-native (expo)

$
0
0

I'm setting up a page where I can Id with a google account. This is my code :

import React from "react"
import { StyleSheet, Text, View, Image, Button } from "react-native"
import * as Google from "expo-google-app-auth";

export default class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      signedIn: false,
      name: "",
      photoUrl: ""
    }
  }
  signIn = async () => {
    try {
      const result = await Google.logInAsync({
        androidClientId:
          "1051966217196.apps.googleusercontent.com",
          iosClientId:
                 "1051966217196.apps.googleusercontent.com",
        scopes: ["profile", "email"]
      })

      if (result.type === "success") {
        this.setState({
          signedIn: true,
          name: result.user.name,
          photoUrl: result.user.photoUrl
        })
      } else {
        console.log("cancelled")
      }
    } catch (e) {
      console.log("error", e)
    }
  }
  render() {
    return (
      <View style={styles.container}>
        {this.state.signedIn ? (
          <LoggedInPage name={this.state.name} photoUrl={this.state.photoUrl} />
        ) : (
          <LoginPage signIn={this.signIn} />
        )}
      </View>
    )
  }
}

const LoginPage = props => {
  return (
    <View>
      <Text style={styles.header}>Sign In With Google</Text>
      <Button title="Sign in with Google" onPress={() => props.signIn()} />
    </View>
  )
}

const LoggedInPage = props => {
  return (
    <View style={styles.container}>
      <Text style={styles.header}>Welcome:{props.name}</Text>
      <Image style={styles.image} source={{ uri: props.photoUrl }} />
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  },
  header: {
    fontSize: 25
  },
  image: {
    marginTop: 15,
    width: 150,
    height: 150,
    borderColor: "rgba(0,0,0,0.2)",
    borderWidth: 3,
    borderRadius: 150
  }
})

On Android it's ok, everthing is fine but in IOS I have that mistake :

Google 400 - That's an error - Error : redirect_uri_mismatch

Can you help me understand where it goes wrong ? I'm new to react native so I need detailed explanations. Thanks for your time and help.

Unhandled JS Exception: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found

$
0
0

The problem is in the title. I run a react-native app on Mac, and then, this error just appear :

Error on the simulator

Obviously, I do a lot a research but I never found any solution... Has anyone a solution about this prob ?

react 16.9.0
react-native 0.61.0
macOS Mojave 10.14.6

How to save downloaded files and view in File app using React Native in iOS?

$
0
0

I am using react-native-fs to download files from server and save them. Once they are downloaded I am using react-native-file-viewer to open them. This process totally works fine: I am able to download and open it in the viewer, but I am not able to save the file in the File application from the viewer, though I can save in iCloud but not in the iPhone. The downloaded file is stored in a place like

/var/mobile/Containers/Data/Application/CCF6CD16-A62A-48BB-92F3-3021195CFE0C/Documents/react-native-pdf.pdf

but this is not shown in the File app.

The code I am using to download and view the file is as follows

    RNFS.downloadFile({
      fromUrl: 'http://www.mywebsite.com/react-native-pdfurl.pdf',
      toFile: `${RNFS.DocumentDirectoryPath}/react-native-pdfurl.pdf`,
    }).promise.then((r) => {
      console.log('yo yo yo ');
      this.setState({ isDone: true });

      const path = `${RNFS.DocumentDirectoryPath}/react-native-pdfurl.pdf`;
      FileViewer.open(path)
      .then(() => {
          // success
      })
      .catch(error => {
          // error
      });

      RNFS.readDir(RNFS.DocumentDirectoryPath).then(files => {
          console.log(files);
      })
        .catch(err => {

            console.log(err.message, err.code);

        });
    });

The readDir gets me the name path of the file saved. But this is not reflected in any folder in the File application. My question is how can I save the file in a way that it shows in the File application.

Viewing all 16558 articles
Browse latest View live


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