braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
71 stars 25 forks source link

Question: `subscribeToInAppMessage` not called (v2.4.1) #77

Closed asherstoppard closed 4 years ago

asherstoppard commented 4 years ago

Good Afternoon,

We're using the in built in app messages from Braze but we need to fire off GA events for impressions and button clicks. I'm attempting to use subscribeToInAppMessage as a starting point to get context of the in app message that will be displayed but it doesn't appear to be called.

Should the following example work if there's an in app message displayed in the application:

appboy.initialize(apiKey, { enableLogging });
appboy.openSession();
appboy.display.automaticallyShowNewInAppMessages();
appboy.subscribeToInAppMessage(handleInAppMessages); // Not Called

Thank you for your help.

wesleyorbin commented 4 years ago

Hi @asherstoppard! Thanks for reaching out. I am unfortunately unable to reproduce this issue and this example should work. How are you triggering In-App Messages when testing out this code?

asherstoppard commented 4 years ago

Hi @wesleyorbin appreciate your help. We just call automaticallyShowInAppMessages and use the in-built behaviour. Just for context and clarity, our full invocation is as follows:

const {default: appboy} = await import(/* webpackChunkName: "appboy-web-sdk" */ 'appboy-web-sdk')
appboy.initialize(apiKey, { enableLogging });

appboy.display.automaticallyShowNewInAppMessages();

appboy.openSession();
window.appboy = appboy;

appboy.changeUser(userId);

appboy.requestContentCardsRefresh();

appboy.subscribeToContentCardsUpdates(callbacks.handleContentCards);
appboy.subscribeToInAppMessage(callbacks.handleInAppMessages);

Hopefully there's something in there that sheds some light. I'll try and get some time today to debug this further and I'll let you know if I find anything.

wesleyorbin commented 4 years ago

Hi @asherstoppard. Try removing the appboy.display.automaticallyShowNewInAppMessages() line and adding appboy.display.showInAppMessage(inAppMessage) to the top of your handleInAppMessages callback. This will have the same net effect as automatically showing the messages and should help us determine the root cause of the issue.

asherstoppard commented 4 years ago

@wesleyorbin Removing automaticallyShowNewInAppMessages and manually applying the message with showInAppMessage worked :+1: I'm not sure why the previous implementation didn't but I'm happy to close this issue on the basis that we're unblocked. If you want me to assist with any further investigation please let me know 🙂Once again, a huge thanks for your assistance.