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

Can we move from native code to react native code in a published Apple app?

$
0
0

I was planning to rewrite an existing IOS app using react native. The existing IOS app is already published in the APP store.

  1. I would like to know if it is possible to completely create a new build and release the new react native app to the app store ? My guess was to just change the bundle identifier of react native app to the one on the existing App to get released. But not sure if it is the right way.

  2. Also if we publish, can we test it before it is released to users or will it immediately reflect ?

  3. The alternate idea would be to create a new app and redirect them to the new app. This is even possible ?


Mapping object to dictionary using React Native iOS Module

$
0
0

I'm trying to call in my native iOS code (in swift) from React Native JavaScript.

Here's my JS snippet:

const identity = {
                  customerEmail: user.email,
                  customerName: `${user.firstName} ${user.lastName}`,
                };

                ChatModule.setupIdentity(identity);

Here's my native implementation:

@objc
func setupIdentity(customer: Dictionary<String, String>) {
    let identity = Identity.createAnonymous(name: customer["name"], email: customer["email"])
    Zendesk.instance?.setIdentity(identity)
}

While both implementations specific to their platforms are right and compile, I can't call into the native module and I'm sure it's related to the method signature being different between react native side and iOS native code.

I was wondering how do I send the correct type over? So it calls into the method properly. Otherwise, right now I'm getting ChatModule.setupIdentity is not a method.

Using addListener (willBlur) is crashing on tester's IOS device

$
0
0

I have created an IOS app using React Native. The app consists of a Song Menu screen and a song screen. On the song screen the user is able to press the play button to play the song.

I am currently testing it out using TestFlight. It is working fine on my phone. However, on my friend's phone it keeps crashing. The error is very generic giving RCTFatal as the error.

However, I have narrowed the problem down to code which stops songs from playing when the user navigates away from the Song page.

The relevant code is here:

export default class Song extends Component {

    playAudio = (file) => {
        var s = new Sound('audio/' + file, Sound.MAIN_BUNDLE, (error) => {
             if (error){
                  console.log('error', error)
             } else {
                   s.play(() => {
                         s.release()
                   })
             }
        })

        /* Problem LINE #1 */
        this.willBlurSubscription = this.props.navigation.addListener(
             'willBlur',
             () => s.release()
        )

    }

    /* Problem LINE #2 */
    componentWillUnmount(){
        this.willBlurSubsciption.remove()
    }

    /* Other code here for displaying UI and the clickable audio button which loads the playAudio function. */
    ...
}

When I remove the subscription code above (shown on two lines) then there is no crash. However, the song will not stop playing after the user goes back to the main menu. When I put the lines back in there it crashes for my tester with the RCTFatal error.

Note: The app crashes whether my tester plays the audio file or not, but always when he navigates back to the Song Menu.

What is the problem with my code? Why is it generating such a cryptic error? And why does my IOS device not crash but his does?

React Native Ios Push Notification Not Working

$
0
0

I use '@react-native-firebase/messaging' module to send notifications. On Android everything works fine, Following is the error log I get when I try const fcmToken = await firebase.messaging().getToken(); on ios device.

NativeFirebaseError: [messaging/unknown] The operation couldn’t be completed. (com.firebase.iid error 1001.)

I have already implemented "react-native-permissions" to grant notification permission.

My AppDelegate.m contains :

if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
 }

Should I add anything else to it? Any help or suggestion will be very helpful. Thanks in advance

Flutter vs React Native vs Java vs Kotlin [closed]

$
0
0

I would love to learn android development, which of Flutter, React Native, Java and Kotlin would you recommend and why? I have a good background in node.js

Detox "Cannot read property 'bindings' of null" error

$
0
0

I tried adding Detox e2e testing to my react native app and I am running into the following error when trying to run a simple test.

enter image description here

I have only installed Detox to the iOS side of the app. The "detox build" command executed perfectly.

Below are the important files from my project.

Package.json

{
 "name": "ExerFit_mobileapp",
 "version": "0.0.1",
 "private": true,
 "scripts": {
   "start": "node node_modules/react-native/local-cli/cli.js start",
   "test": "jest"
 },
 "dependencies": {
   "bcrypt": "^3.0.7",
   "firebase": "^5.5.9",
   "moment": "^2.24.0",
   "native-base": "^2.13.8",
   "qs": "^6.9.0",
   "react": "16.3.1",
   "react-native": "0.55.4",
   "react-native-custom-tabs": "^0.1.7",
   "react-native-datepicker": "^1.7.2",
   "react-native-navigation": "^3.7.0",
   "react-native-vector-icons": "^6.6.0",
   "react-navigation": "^2.18.2",
   "rn-apple-healthkit": "^0.6.5",
   "switch-button-react-native": "^1.0.3"
 },
 "devDependencies": {
   "babel-jest": "24.9.0",
   "babel-preset-react-native": "4.0.1",
   "detox": "^15.1.4",
   "jest": "24.9.0",
   "react-test-renderer": "16.3.1"
 },
 "jest": {
   "preset": "react-native"
 },
 "detox": {
   "test-runner": "jest",
   "specs": "e2e",
   "configurations": {
     "ios.sim.debug": {
       "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ExerFit_mobileapp.app",
    "build": "xcodebuild -workspace ios/ExerFit_mobileapp.xcworkspace -scheme ExerFit_mobileapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
    "type": "ios.simulator",
    "name": "iPhone 7"
  }
}
}
}

config.json

{
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}

init.js

const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');


jest.setTimeout(120000);

jasmine.getEnv().addReporter(adapter);

jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => {
  await detox.init(config);
}, 300000);

beforeEach(async () => {
  await adapter.beforeEach();
});

afterAll(async () => {
  await adapter.afterAll();
  await detox.cleanup();
});

How do I address React Native running poorly on physical iOS device vs Simulator?

$
0
0

I've recently finished building an app using React Native, and I'm in the process of shaking out the last remaining bugs. While the app performs exactly as it should in Simulator (compiled in Xcode using the release settings), on my physical iOS device it's ridden with subtle layout bugs and rendering problems. Calls to setState() appear to be failing after certain events, for example, when I make a call to fetch() I set an item in state to show a loading image just before the call, when the response is received state is changed to restore the previous image. On Simulator this works fine, on the physical device it correctly changes to the loading icon but fails to switch back. As far as I'm aware, there's no differences in the build between Simulator and the physical device, so what's the likely culprit?

Firebase, React Native, Expo - How would I set up a 'Ping/(Similar to Facebook's Poke)' feature so that each users can Ping each other?

$
0
0

So I've got my authentication system setup already for the application (basic signup, login, and log out). I wanted to work on an app that generally display a list of users and the user on the device can pick which user they want to 'Ping' to.

In result, the recipient user would receive the notification of some sort that shows another user has pinged them (*Only while using the app).

My initial thoughts/ideas are:

  • Once a user is signed up: their data such as Full Name, Email, UID, (Password??) would be stored in the Firebase Real Time database system. (I also plan to allow users to setup their own profile image on the profile home screen, which their image could perhaps be stored in the database too?)

  • Another screen to display a list of users registered with the app. (I plan to use some additional technology to help the app identify only close proximity users in this list, *but for now let's say there is a screen showing a simple list of users)

  • Users then could choose which users they want to ping to (I could use Modal to display this action menu)

My main queries & questions are:

  • How would I setup a function that would retrieve individual user data say the user's UID (which would initially be stored in the Firebase Database) and send some sort of a message/notification (perhaps in an Alert box etc.) to other user using these data?

  • If first function works/is possible, how would I setup a function that let's the recipient ping them back (Of course with the ability to choose to dismiss/ignore this Ping notification)?

  • My last question is, if any of these are possible?

I would greatly appreciate any sort of help, guides, or hints on creating such system. I have only recently just taught myself JavaScript and using the React Native framework, and thought this would be a good little project to start with.

Thank you for your time.


dyld: Library not loaded: @rpath/MapboxMobileEvents.framework/MapboxMobileEvents

$
0
0

I am just trying to install mapBox in my project, and I'm getting this error:

dyld: Library not loaded: @rpath/MapboxMobileEvents.framework/MapboxMobileEvents Referenced from: /Users/digitalgravity/Library/Developer/CoreSimulator/Devices/D6A86A86-478C-4988-9BFF-1A0DA6B05566/data/Containers/Bundle/Application/049C7FB8-4B79-4428-8AF7-6D9D1FF2846B/ADFD.app/Frameworks/Mapbox.framework/Mapbox Reason: image not found

How would I set up a 'Ping/(Similar to Facebook's Poke)' feature so that each users can Ping each other?

$
0
0

I've got my authentication system setup already for the application (basic signup, login, and log out). I wanted to work on an app that generally display a list of users and the user on the device can pick which user they want to 'Ping' to.

In result, the recipient user would receive the notification of some sort that shows another user has pinged them (only while using the app).

My initial thoughts/ideas are:

  • Once a user is signed up: their data such as Full Name, Email, UID, (Password??) would be stored in the Firebase Real Time database system. (I also plan to allow users to setup their own profile image on the profile home screen, which their image could perhaps be stored in the database too?)

  • Another screen to display a list of users registered with the app. (I plan to use some additional technology to help the app identify only close proximity users in this list, *but for now let's say there is a screen showing a simple list of users)

  • Users then could choose which users they want to ping to (I could use Modal to display this action menu)

My main queries & questions are:

  • How would I setup a function that would retrieve individual user data say the user's UID (which would initially be stored in the Firebase Database) and send some sort of a message/notification (perhaps in an Alert box etc.) to other user using these data?

  • If first function works/is possible, how would I setup a function that let's the recipient ping them back (Of course with the ability to choose to dismiss/ignore this Ping notification)?

  • My last question is, if any of these are possible?

I would greatly appreciate any sort of help, guides, or hints on creating such system. I have only recently just taught myself JavaScript and using the React Native framework, and thought this would be a good little project to start with.

Building a react native SDK to be used by IOS

$
0
0

I am building an SDK using react native to be used by native android and IOS apps. I was trying to make the SDK easy to be set up, so the SDK user does not have to use yarn or npm. Based on some blogs, android seems to be doable. However, with IOS i am having some troubles adding the react native dependencies.

React native docs suggests adding pods using downloaded node modules. Is there any way for the SDK user to only add the SDK pod to his/her app without adding any react native pods? I am new to cocoapods and as far as i understand IOS searches for pods on the cocoapods repo only.

I tried uploading all the react native dependencies to a public repository so the SDK user can add all the pods to his/her Podfile. If someone wants to use the SDK the Podfile would look like this:

  pod 'MySdk', :path => '../my-sdk'

  repository = 'git@github.com:AbdullahAsendar/react-native-ios-pod.git'
  tag = '0.61.5'

  pod 'FBLazyVector', :git => repository, :tag => tag
  pod 'FBReactNativeSpec', :git => repository, :tag => tag
  pod 'RCTRequired', :git => repository, :tag => tag
  pod 'RCTTypeSafety', :git => repository, :tag => tag
  pod 'React', :git => repository, :tag => tag
  .... THE REST OF THE PODS

This may be acceptable but not having to add all these pods would be better,

Also, can i create a pod for each one of the dependencies and upload these pods to CocoaPods? This way i would reference these pods in my SDK and the SDK user will only have to add the SDK pod.

React Native Linking URL returns null during iOS app launch

$
0
0

I am unable to handle Linking url in iOS app when app launches. I am getting url null at the time of iOS app launch. Working properly when app is already running. Below is the code I am using for the same. I added getInitialURL() and addEventListner() both as some online source suggested to that getInitialURL() works during app launch. Please help solving the issue. I use the following versions:

"react": "16.8.3", "react-native": "0.59.8",

Linking.getInitialURL().then((event) => {
            if (event) {
                Logger.log("Url from getInitialUrl" + event)
            }
        }).catch(err => {
            console.warn('An error occurred', err);
        });

        Linking.addEventListener('url', (event) => {
            console.log("Add Event Listener" + event)
        });

I have followed official doc enter link description here for iOS Lining integration.

Cant build react native project in Xcode

$
0
0

I try to build a "fresh" react-native project in Xcode and run it on the phone but it says library not found for -lDoubleConversion.

When I build it with npx react-native run-ios it runs fine in the simulator.

What am i missing? I found on the net that i am not the only one with this issue but i cant find the solution.

I spent already two days trying to find some solution and I have to say that I slowly stop believing that people are using react to build ios applications :-(

Thanks for any hint Jan

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

$
0
0

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

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

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

Here's my setup

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

Can't update pods to the latest version

$
0
0

I'm using react-native and I am trying to update the pods by using

pod update

But it updates nothing. However, when I use

pod outdated

It shows this

    Updating spec repo `master`
    $ /usr/bin/git -C /Users/IG/.cocoapods/repos/master fetch origin --progress
    remote: Counting objects: 15, done.        
    remote: Compressing objects: 100% (14/14), done.        
    remote: Total 15 (delta 11), reused 0 (delta 0), pack-reused 0        
    From https://github.com/CocoaPods/Specs
        1bb3a72da66..f6d4f6f0e14  master     -> origin/master
    $ /usr/bin/git -C /Users/IG/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
    master
    $ /usr/bin/git -C /Users/IG/.cocoapods/repos/master reset --hard origin/master
    HEAD is now at f6d4f6f0e14 [Add] ScanbotSDK 0.0.2
    Analyzing dependencies
    The color indicates what happens when you run `pod update`
    <green>      - Will be updated to the newest version
    <blue>   - Will be updated, but not to the newest version because of specified version in Podfile
    <red>        - Will not be updated because of specified version in Podfile

    The following pod updates are available:
    - Firebase 3.17.0 -> (unused) (latest version 4.13.0)
    - FirebaseAnalytics 3.9.0 -> 3.9.0 (latest version 4.2.0)
    - FirebaseCore 3.6.0 -> 3.6.0 (latest version 4.0.20)
    - FirebaseInstanceID 1.0.10 -> 1.0.10 (latest version 2.0.10)
    - FirebaseMessaging 1.2.3 -> 1.2.3 (latest version 2.2.0)
    The following pods are deprecated:
    - Google

But my podfile doesn't specify any version:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
    pod 'Google/SignIn'
    pod 'Firebase/Core'
    pod 'Firebase/Messaging'
end

I have react-native 0.47.2 xcode 9.2 cocoapods 1.5.0


How to prevent iOS screenshot in react-native

$
0
0

In my application I want to disable screen shots function for IOS in React-native.

Please suggest me any working package or any native code which can disable screen shots in IOS.

What is the best practice to include third party ios sdk framework in react-native module library?

$
0
0

I am trying to include ios sdk framework in my react-native module library. I turned always embed swift standard library to Yes in build setting. Everything compiles fine.

Then I include the node module in an app using npm i react-native-my-framework, open sampleapp.xcworkspace and build in XCode, I get an error MyFramework/MyFramework-Swift.h not found. I tried following permutation combinations:

  1. Put MyFramework to Frameworks, Library and Embedded Contents. and tried some other combination of build settings.
  2. Set the framework search path in the library project - $(PROJECT_DIR)/../node_modules/react-native-my-framework/ios/
  3. I manually included libMyFramework.a to Libraries group.

But I am still facing the same issue. What am I missing here?

Also, MyFramework is not on Cocoa pods

Update:

Now MyFramework is available on Cocoapods

iOS Native Module - Invariant Violation: Native module cannot be null

$
0
0

I have an issue with upgrading react-native version from 0.59.10 to 0.61.5. We are using our own native modules and it seems like to be problem with them. This problem I have only on iOS.

ERROR:

Invariant Violation: Native module cannot be null.

React Native version:

System:
   OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 70.44 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 11.5.0 - /usr/local/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 28.0.3, 29.0.0, 29.0.1, 29.0.2
      System Images: android-26 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native: 0.61.5

GITHUB: https://github.com/facebook/react-native/issues/27975

UIDocumentInteractionController menu does not dismiss (React Native 0.61.5) iOS 13+

$
0
0

I have an issue with UIDocumentInteractionController which is used to open a PDF document.

The problem at this point is when user interacts with the menu my clicking on the Open in {app_name} action, the menu itself fails to close after user interaction leaving the menu open when user comes back to the app.

Dismissing the menu at this point requires user to tap twice on the X in order for menu to be dismissed.

I also tried to close the menu dynamically when app returns to active state by running dismissMenuAnimated on UIDocumentInteractionController instance but it does not work in this case, it does however dismiss the dialog if no interaction was made on it and the method is called.

One note, this issue is only present on never iOS version 13+. On older OS the menu is closed after interaction as expected.

We tried using this code other than all react-native stuff we tried:

    @property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;
@property (atomic) CGRect rect;

RCT_EXPORT_METHOD(openDocumentInteractionControllerWithFileURL:(NSURL *)fileURL){
    if (!fileURL) {
        // Return NO because there was no valid fileURL.
        return;
    }

    UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

    // Open "Open in"-menu
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    self.documentInteractionController.delegate = self;

    BOOL sucess; // Sucess is true if it was possible to open the controller and there are apps available

    sucess = [self.documentInteractionController presentOpenInMenuFromRect:self.rect inView:rootCtrl.view animated:YES];


    if(!sucess){
        // Inform app that the activity has finished
        // Return NO because the service was canceled and did not finish because of an error.
        // http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActivity_Class/Reference/Reference.html
    }
}

RCT_EXPORT_METHOD(dismissDocumentInteractionController){
    // Hide menu
    [self.documentInteractionController dismissMenuAnimated:YES];
}

But without success.

How to implement an application-wide search bar?

$
0
0

It seems to be a pretty common task to have an application-wide search bar in the header. Unfortunately, I haven't found some ready recipes on how to accomplish it the right way. My solution was to place a custom SearchBox component in the React Native Navigation header using headerTitle:

static navigationOptions = ({navigation}) => {
     headerTitle: () => (<SearchBox ... />)

It had its drawbacks, e.g. using "static" variables to pass state and behavior between the application and the component. But it worked so far. Now, after moving to RNN 4.1.1, it stopped working because of the specifics of how the header is implemented in the RNN:

enter image description here

TextInput now doesn't fill the header's width and doesn't handle the text input properly.

enter image description here

I am looking for a way to implement an application-wide search bar in RN, that features the following properties:

  • it appears application-wide;
  • its contents can be modified by a user, who wants to perform the search;
  • when the user navigates back its contents conform to the shown page (e.g. if the user typed a query on page A and then got redirected to page B, so when they go back to the page A the search box contains "Page A" and not the query they typed);
  • it supports suggestions (an also tricky thing to do).

I believe some of you using RN in production must have addressed this task and have your own approaches. Sharing them here would be much appreciated.

Viewing all 16536 articles
Browse latest View live


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