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

Can't fetch HTML content when using inAppHandler callback

Open kaushikwavhal opened this issue 4 months ago • 1 comments

Hi Iterable team,

When trying to fetch HTML content using IterableSDK.inAppManager.getHtmlContentForMessage called from within IterableConfig's inAppHandler callback, i get an error message that says the message could not be found and apparently the messageId from this message cannot be found in any of the message fetched via getMessages() call as well.

Error: Could not find message with id: <messageId>

Versions: "@iterable/react-native-sdk": "^1.3.13", "react-native": "0.72.10",

kaushikwavhal avatar Mar 26 '24 19:03 kaushikwavhal

Have the same issue. What worked for me is that I fetch html content in inAppHandler after a setTimeout with 0 interval. Looks like some race condition

config.inAppHandler = (message: IterableInAppMessage) => {
    Iterable.inAppManager.getHtmlContentForMessage(message).catch(() => {
       // here will be error
    })
    setTimeout(() => Iterable.inAppManager.getHtmlContentForMessage(message).then(() => {
        // here won't be error
    }), 0)
    return IterableInAppShowResponse.skip
  }

anta-semenov avatar Apr 03 '24 17:04 anta-semenov