braze-inc / braze-react-native-sdk

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

[Bug] `getContentCards` doesn't trigger a refresh on iOS #195

Closed Minishlink closed 1 year ago

Minishlink commented 1 year ago

Which Platforms?

iOS

Which React Native Version?

0.70

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

2.0.2

Repro Rate

100%

Steps To Reproduce

Flow A:

  1. import Braze from "@braze/react-native-sdk".
  2. Braze.getContentCards().then(console.log)
  3. Run the app.

Flow B:

  1. import Braze from "@braze/react-native-sdk".
  2. Braze.getContentCards() (with the workaround below)
  3. Braze.logContentCardDismissed(cardId)
  4. Call Braze.getContentCards()

Expected Behavior

Example A : It should return fresh content cards like on Android. Example B : The dismissed card is dismissed like on Android.

Actual Incorrect Behavior

Flow A: It returns nothing. You have to use a workaround to do what the Android SDK is doing

await new Promise<void>(resolve => {
    const listener = Braze.addListener(Braze.Events.CONTENT_CARDS_UPDATED, () => {
       listener.remove();
          resolve();
     });
     Braze.requestContentCardsRefresh();
});
await Braze.getContentCards();

Flow B: The dismissed card isn't dismissed Workaround is to call Braze.requestContentCardsRefresh() after logDismiss (but subject to race condition)

Verbose Logs

No response

Additional Information

No response

hokstuff commented 1 year ago

Hi @Minishlink,

We have an example in our sample app using the getContentCards() API. You can work with that sample app with your own API key and endpoint to try to understand the sample's current behavior.

Can you contact support@braze.com with more information about:

Thanks!

Minishlink commented 1 year ago

You can see clearly the difference of behaviour between Android and iOS here:

hokstuff commented 1 year ago

Hi @Minishlink,

Thanks for linking the code snippets. We have filed this issue internally and will slate the change to be done in a future release to bring the iOS behavior in line with the Android behavior.

hokstuff commented 1 year ago

Hi @Minishlink,

We have released version 3.0.0 which addresses this issue that was introduced in version 2.0.0. The behavior on iOS should now match Android's behavior when using custom UI. Let us know if you run into issues - thanks!

WojciechRupik commented 2 months ago

Guys, i am struggling with same issue. I got cards data on android but i can't get it on ios. Currently i am working on simulator but i shouldn't be a problem.

I am using this version: "@braze/react-native-sdk": "12.1.0"

ios code

android code