react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

How to access rootView in iOS native code

Open messense opened this issue 9 years ago • 6 comments

I want to integrate react-native-sentry. It needs to add some native code:

[RNSentry installWithRootView:rootView];

Ref: https://docs.sentry.io/clients/react-native/#client-configuration

So this question is how can I access rootView in AppDelegate.m when using react-native-navigation.


Environment

  • React Native Navigation version: v2.0.0-experimental.276
  • React Native version: 0.41
  • Platform(s) (iOS, Android, or both?): iOS

messense avatar Apr 06 '17 08:04 messense

Navigation has multiple RCTRootViews (that's the essence of this project), so if anything, you should use the installWithBridge method. You can currently access the bridge by

[[RCCManager sharedInstance] getBridge]

DanielZlotin avatar Apr 06 '17 11:04 DanielZlotin

@DanielZlotin Hi! But I still don not know how to use it. Thanks a lot.

zhaiyjgithub avatar May 22 '17 09:05 zhaiyjgithub

@zhaiyjgithub instead of: [RNSentry installWithRootView:rootView]; use this one: [RNSentry installWithBridge:[[RCCManager sharedInstance] getBridge]];

Mindaugas-Jacionis avatar May 23 '17 08:05 Mindaugas-Jacionis

I used [RNSentry installWithBridge:[[RCCManager sharedInstance] getBridge]]; in my AppDelegate.m, but my app just gets stuck on the launch screen (iOS). Xcode logs seems to show it's stuck on downloading updates from CodePush, then nothing more. Anyone else with experience integrating with other native libs like CodePush, with or without interference?

fungilation avatar Dec 31 '17 01:12 fungilation

@Mindaugas-Jacionis Thank you, that definitely resolved my issue!

andrewzey avatar May 11 '18 18:05 andrewzey

In react-native-navigation v2 the RCCManager file is removed and for integrating sentry you can use [RNSentry installWithBridge:[ReactNativeNavigation getBridge]]; in AppDelegate.m file.

VahidBo avatar Aug 26 '18 07:08 VahidBo