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

subscribetToTopic iOS react native firebase

$
0
0

When I try to subscribe to topic in iOS device(iPhone) it fail strangely...

In debug when code reaches messaging().subscribeToTopic('adminDevices'); it does not go on without any errors or warning

I have permission and i have FCM token, i try to subscribe after these operations and when i send message with token it works.

The others messaging() functions works correctly. I have already tried to move it in App.js and before and after getToken()

On Android all works correctly.

Thanks


subscribeToTopic iOS react native firebase

$
0
0

When I try to subscribe to topic in iOS device(iPhone) it fail strangely...

In debug when code reaches messaging().subscribeToTopic('adminDevices'); it does not go on without any errors or warning

I have permission and i have FCM token, i try to subscribe after these operations and when i send message with token it works.

The others messaging() functions works correctly. I have already tried to move it in App.js and before and after getToken()

On Android all works correctly.

Thanks

What is the meaning of 'No bundle URL present' in react-native?

$
0
0

When I run a react-native project, I get a error no bundle URL present , but I don't know what mistakes I do, I was very confused.

enter image description here

"unrecognized selector sent to instance" when setting a property on react-native

$
0
0

I'm trying to link my Swift view with my React-Native project. I figured out how to display it, but now when I'm trying to set a property, I'm having this error message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Switch setMessage:]: unrecognized selector sent to instance 0x7f96b270de70'

In my react-native code, I'm doing:

const SwitchNative = requireNativeComponent('Switch', Switch);

class Switch extends Component {
  render() {
    return (
        <SwitchNative message="message will be" style={this.props.style} />
    );
  }
}

Then doing this in my SwiftBridge:

// SwiftBridge.h

#import "RCTView.h"

@interface SwitchBridge : RCTView

  @property (nonatomic, assign) NSString *message;

@end

// SwiftBridge.m

#import "RCTBridgeModule.h"
#import "RCTViewManager.h"
#import "SwitchBridge.h"

@interface RCT_EXTERN_MODULE(SwitchManager, RCTViewManager)

  RCT_EXPORT_VIEW_PROPERTY(message, NSString)

@end

Then finally I have this in my Swift class Switch.swift:

...
public func setMessage(message: String) {
  NSLog("It's working well");
}
...

Not sure why it can't find my setMessage function.

Page break in html doesn't work as expected when I print the html with Print API in Expo (iOS)

$
0
0

I tried to add page break to an html and print the html using Expo Print API in my Expo app.

<html>
<body>
<h1>Page 1</h1>
<div class="pagebreak"></div>
<h1>Page 2</h1>
<div class="pagebreak"></div>
<h1>Page 3</h1>
<div class="pagebreak"></div>
</body>
<style>
@page print {
    .pagebreak { break-before: page; }
}
@media print {
    .pagebreak { break-before: page; }
}
@page print {
    .pagebreak { page-break-before: always; }
}
@media print {
    .pagebreak { break-before: always; }
}
</style>
</html>

However in iOS, none of these styles work.

enter image description here

But one of them work in android. Keep below style only,

@media print {
    .pagebreak { break-before: page; }
}

then pick android mode in expo snack, then we find the expected page break.

enter image description here

The reproducible example: Expo snack example. I care about iOS mode only, so no need to worry about android or web.

Note: the question is similar to How to avoid page breaks inside content sections in output PDF generated from HTML using Expo.printToFileAsync on iOS but that question does not provide a reproducible example and its description contains some redundant information. That's why I create a new question here.

How to display Device folder in React Native

$
0
0

I want to display my device folder for Gallery app development in React Native. i was searched lot at Google but no improvement. anyone have an idea, please share it.

How to get the Current Date in ReactNative?

$
0
0

I am building my first ReactNative iOS and Android app. I am an iOS coder with Swift and Obj-C. How do I fetch the current date using ReactNative.

Shall I use Native Modules or is there an ReactNative API from which I can get this data ?

Is it possible to combine React Native with socket.io

$
0
0

I was working on an app with Phonegap + React.js and Socket.io. However, then React-Native got released and the native feel is amazing.

I tried getting socket.io-client working with React Native, but unfortunately without much success. I did some research and I'm getting the exact same errors as described in this issue: https://github.com/facebook/react-native/issues/375

The comments on the issue said to try and use the fetch API to fetch JS modules, but I think I'm doing this wrong:

var socketScript;    
fetch('https://cdn.socket.io/socket.io-1.2.0.js')
    .then(function(response) {
        socketScript = response._bodyText;
    }).done(function() {
        var socket = socketScript.io();
    });

This returns an undefined is not a function.

Is there any way to make socket.io-client work with React Native? Or am I looking at this the wrong way? Perhaps there are other, better suited solutions?


How to change iOS/Android project folders in React Native

$
0
0

I am new to React Native and I want to move android and ios folders to a folder that I've created named platforms. I've moved the folders and ran:

react-native run-ios --project-path ./platforms/ios

Got an error about the ../node_modules/react-native/scripts/react-native-xcode.sh script, changed it to ../../node_modules/react-native/scripts/react-native-xcode.sh as I've moved the folder one directory in.

It starts building (it finds the xcodeproj) and fails with:

/Users/Can/Documents/Programming/React Native/MyApp/platforms/ios/MyApp/AppDelegate.h:8:9: fatal error: 'React/RCTBridgeDelegate.h' file not found

info #import <React/RCTBridgeDelegate.h>

(since my focus is on iOS, I haven't checked Android)

How can I properly move the ios and android folders to my custom folder and build React Native app properly?

Deploy bare react native for iOS after expo eject in window

$
0
0

I'm developing an app with React Native using Expo (managed workflow). The app is not finished yet but I need to use expo eject and be able to continue to develop it as a Bare workflow.

Right now I'm on a Windows machine and the eject will create only the Android folder and not iOS.

(Of course, what I want to do is deploy also for iOS).

If I eject and I continue the development on windows, it will be possible, later, once the app it will be finished, to deploy it also for iOS, COPING the entire project and reINSTALLING the same packages on a mac?

react-native ios Podfile issue with "use_native_modules!"

$
0
0

In my react-native project (react-native@0.60) in the ios/ dir I run pod install and get this error:

[!] Invalid `Podfile` file: no implicit conversion of nil into String.

 #  from /Users/coryrobinson/projects/hhs2/ios/Podfile:37
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

I haven't added or changed anything in this Podfile - it's all react-native generated. (I'm not experienced in iOS dev so this might be a simple fix, I just don't know what to look for :-|) Thanks for any help!

Here is my Podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'hhs2' do
  # Pods for hhs2
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  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-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
  pod 'RNFS', :path => '../node_modules/react-native-fs'

  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 '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 'hhs2Tests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

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

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

end

Flatlist of videos does not render in react native

$
0
0

I have a list of videos rendering, and after 32 videos render I receive this error:

domain: "AVFoundationErrorDomain", code: -11839

This is because iOS will only allow 32 video players to be instantiated at once. How, then, can I get rid of some of the video players? The Flatlist is horizontal and wrapped by a vertically scrolling recyclerlist view. The code for the flatlist is here:

<FlatList
                    ref={(ref) => { this.flatListRef = ref }}
                    data={this.state.posts}
                    extraData={this.state}
                    onScroll={(e) => this.pauseAll(e)}
                    showsHorizontalScrollIndicator={false}
                    scrollEnabled={this.state.isPortrait}
                    horizontal={true}
                    renderAheadOffset={0}
                    initialNumToRender={3}
                    windowSize={3}
                    removeClippedSubviews={true}
                    pagingEnabled={true}
                    keyExtractor={(row, id) => id.toString()}
                    renderItem={(row, id) => (this.renderVideos())}
/>

My understanding is that recyclerlistview would not hold each row in memory, only the dimensions, but all 32 videos are in memory.

Another way to put this is that original video players do not unmount when out of view?

How to navigate one page to another page using React Native?

$
0
0

my scenario, I am trying to navigate login.js page to home.js page. I need to implement navigation but need to hide into login.js but need to show into home.js. Here, login button click to navigate home page. The navigation should support iOS and Android both platform.how to achieve this?

App.js

import React, { Component } from 'react';
import { StyleSheet, Text, View} from 'react-native';
import Login from './components/Login';

export default class App extends Component {
  render(){
    return(
      <View style={styles.container}>
          <Login/>
      </View>
    );
  }
}

Login.js

import React from 'react';
import { View, Text, StyleSheet, TextInput, TouchableOpacity, ActivityIndicator } from 'react-native';

export default class Login extends React.Component {
    state = {
       isLoading: false 
    };

    showLoader = () => {
        this.setState({ isLoading: true });
    };

    // Login Click Action
    loginclick = () => {
        //this.showLoader();
        console.log('Login Clicked...'); // Need to move home page
    }

    render() {
        return (
            <View style={styles.container}>
                <TouchableOpacity style={styles.button} onPress={(this.loginclick)}>
                    <Text style={styles.btntext}>Sing In</Text>
                </TouchableOpacity>
                <View style={styles.activityview, styles.horizontal}>
                    <ActivityIndicator size="large" animating={this.state.isLoading} color='#fff' />
                </View>
            </View>
        );
    }
}

Package.json

   {
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/masked-view": "0.1.5",
    "expo": "~36.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-gesture-handler": "~1.5.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-safe-area-context": "0.6.0",
    "react-native-safe-area-view": "^1.0.0",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-web": "~0.11.7",
    "react-navigation": "^1.6.1",
    "react-navigation-stack": "^2.0.16"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.0.0",
    "@babel/core": "^7.0.0"
  },
  "private": true
}

dyld: library not loaded: AlamofireObjectMapper Reason: image not found

$
0
0

I have added into my react native app's podfile a pod (NewPod) which has dependecy to AlamofireObjectMapper. I am trying to run my project and I get the error:

dyld: Library not loaded: @rpath/AlamofireObjectMapper.framework/AlamofireObjectMapper Referenced from: /Users/xxx/Library/Developer/CoreSimulator/Devices/74176933-8DFE-4A36-AA0C-9E7AC01EF038/data/Containers/Bundle/Application/031D8C1A-6B3D-418C-8728-91B0852DA637/XXX.app/Frameworks/NewPod.framework/NewPod Reason: image not found

I tried to add into my linked Binary and Libraries the framework but it is not available, I can only find libAlamofireObjectMapper.a which is not enough. Error remains. I am using xcode 11.3.1

Any thoughts?

Can I shorten XCode Archive time on public libs 'react-xxx' under 'Pods' project?

$
0
0

My XCode Archive took 10+ minutes. Buildtime mostly on react-xxx targets under project 'Pods', rather than my own code. (I mostly use VS Code for react native and don't use XCode) Could I do anything to skip building those react-xxx targets? enter image description here

enter image description here


How to restriction React native app uninstall

$
0
0

I m developing a parental control app using react-native. basically this app does some basic parental control function. Is any way to restrict app uninstall in android. because this has some requirement to restrict app uninstall without parent permissions.

Xcode doesn't include files to build on iOS 13.3

$
0
0

I just update my iPhone to iOS 13.3 and now I'm unable to build a simple react native app, I tried to download the newest xcode version (Xcode 11.3 beta) wich supposed to include the files but it doesn't.

macOS Mojave 10.14.6

Can't run react native project for ios

$
0
0

I am developing react native app and i am new in react-native, firstly I have worked for android platform and successfully build apk file. Now i want to run it for ios version with the command react-native run-ios from my mackbook but it's throws an error:

note: from starting i have developed this app on macbook

user-MacBook-Pro:myApp user$ react-native run-ios
error Cannot read property 'podfile' of null. Run CLI with --verbose flag for more details.
TypeError: Cannot read property 'podfile' of null
    at warnAboutPodInstall (/Users/user/project/myApp/node_modules/@react-native-community/cli-platform-ios/build/link/warnAboutPodInstall.js:43:90)
    at Object.runIOS [as func] (Users/user/project/myApp/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:80:36)
    at Command.handleAction (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:164:23)
    at Command.listener (Users/user/project/myApp/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:198:13)
    at Command.parseArgs (Users/user/project/myApp/node_modules/commander/index.js:651:12)
    at Command.parse (Users/user/project/myApp/node_modules/commander/index.js:474:21)
    at setupAndRun (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:237:24)
    at Object.run (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:184:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:117:7)

Podfile

 platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

 target 'myApp' do
  # Pods for myApp
  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 'myAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

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

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

end

please help me who knows the solution. Thanks in advance.

Firebase.h file not found with CocoaPods

$
0
0

I am trying to add Firebase into my project. I just added below pods into my Xcode project.

  pod 'Firebase'
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  pod 'Firebase/Database'
  pod 'Firebase/Auth'

After installing podfile, I try to import firebase into my project. But it gives me an error that Firebase.h is not found.

na

Above issue will occur when I uncheck the Run script only when installing from [CP] Check pods Manifest.lock. After that I will installed pod using pod install. And then issue will occur.

Error which I got after uncheck the checkbox:

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

What are some gotchas when converting a react.js app to react-native ios?

$
0
0

I am in the process of trying to convert a react.js app to react-native. What are some common pitfalls when doing this?

I do not see any tutorials of people doing this..

So I have another pre-existing React-Native app already referenced by my iOS project as a framework.. will this cause any issues by adding this new additional react-native app?

Should I be expecting a lot of time resolving js-libraries, having a hard time converting html components / styles to react?

Would it just make sense importing my react.js app into the framework (I have access to the framework's react-native source code).. instead of creating a new rn app?

Viewing all 16554 articles
Browse latest View live


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