react-native-health-connect icon indicating copy to clipboard operation
react-native-health-connect copied to clipboard

How to setup the library when using Wix react-native-navigation?

Open predescu opened this issue 1 year ago • 2 comments

Describe the bug I'm struggling to set up the library on my React Native App. I'm using Wix react-native-navigation, and it looks like there is a type mismatch. It would be great if we have an example for this scenario.

In this case, the MainActivity extends NavigationActivity instead of ReactActivity

Screenshots Screenshot 2024-05-02 at 14 46 32

Environment:

  • Health Connect Version: 2.0.1
  • React Native Version: 0.73.5
  • New architecture enabled: No

predescu avatar May 02 '24 13:05 predescu

Hey!

Thanks for noticing this. Can you please share a minimal reproducible so I can work on it? Thanks :)

matinzd avatar May 03 '24 10:05 matinzd

Hey @matinzd I've put together a minimal reproducible code (react-native + react-native-navigation + react-native-health-connect). You can find it at this location: https://github.com/predescu/rnn-health-connect

I've commented out the updates on the android/app/src/main/java/com/rnnhealthconnect/MainActivity.kt file so the app can start.

On the screen, there si a button to request the permissions. When you press the button, the app will crash because the HealthConnectPermissionDelegate.setPermissionDelegate(this) code line is missing from the MainActivity.kt

predescu avatar May 04 '24 19:05 predescu

I've run into the same issue. RNN's NavigationActivity extends AppCompatActivity rather than ReactActivity. Anything that extends from ComponentActivity will have registerForActivityResult(), so could setPermissionDelegate() just accept a ComponentActivity?

cribcutkiran avatar May 29 '24 18:05 cribcutkiran