braze-inc / braze-react-native-sdk

Public repo for the Braze React Native SDK
https://www.braze.com
Other
64 stars 84 forks source link

[Bug]: Braze.getInitialUrl() doesn't use the callback on Android #226

Closed m-berenson closed 1 year ago

m-berenson commented 1 year ago

Which Platforms?

Android

Which React Native Version?

0.71.7

Which @braze/react-native-sdk SDK version?

6.0.1

Repro Rate

100%

Steps To Reproduce

  1. Upgrade @braze/react-native-sdk to 6.0.1
  2. Use Braze.getInitialUrl()
  3. Run Android App

Expected Behavior

Expected Braze.getInitialUrl() callback return null value on Android

Actual Incorrect Behavior

Braze.getInitialUrl() callback does not return a anything on Android

Verbose Logs

No response

Additional Information

I was using Braze.getInitialURL() for both iOS & Android platforms. We use it with promises: new Promise(resolve => Braze.getInitialURL(resolve)).

That works well in v5.x.x but when upgrading to 6.0.1 when running on Android it got stuck on the first screen of the app. On iOS worked well.

Digging deeper into the code I found that the Android bridge for 6.0.0 has an empty implementation for getInitialUrl. (never use the callback) https://github.com/braze-inc/braze-react-native-sdk/blob/21aa2517539eaab86ddae1522377fa32118e748a/android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt#L12-L14

And in the JS side, it checks for this.bridge.getInitialUrl to be defined, otherwise it call the callback function with null. Since starting 6.0.0 getInitialUrl is defined but does not have any implementation, it seems the callback argument is never called. https://github.com/braze-inc/braze-react-native-sdk/blob/21aa2517539eaab86ddae1522377fa32118e748a/src/braze.js#L48-L62

In the React Native layer I was waiting to that callback but the promise never resolves a value. I think it is due the callback on Android bridge is defined but never uses the callback.

Fixed the issue checking if Android or iOS in order to call Braze.getInitialUrl(), but it took me a bit to understand the root problem 😅 .

radixdev commented 1 year ago

Hi @m-berenson ,

We've filed this internally to take a look at and will update this issue with progress.

Minishlink commented 1 year ago

Hello, I can confirm this issue after upgrading from 5.x to 6.x. In a usual react-navigation setup, this also blocks rendering of the first route since the promise for getting the initial route is pending indefinitely because the Braze callback is not called.

hokstuff commented 1 year ago

Hi @m-berenson @Minishlink,

We have just released React Native SDK version 7.0.0 which fixes this issue.

Thanks!