Closed kevinrodrigues closed 4 years ago
Hi @kevinrodrigues,
The backend determines which content cards to send each user, so this behavior is expected since the SDK always starts with an empty array of cards for new users.
As you mentioned, you should be using subscribeToContentCardsUpdates
with something like below:
// initialize, openSession, etc
appboy.subscribeToContentCardsUpdates(contentCards => {
options.callbacks.handleContentCards(contentCards.cards);
});
Please let me know if this does not work for you or if I misunderstood your issue. Note it may take some time for the callback to run depending on how long it takes for the sync
call to come through.
Also, if you're using 2.4.0 and the core version of the SDK (appboy.core.min.js
), I highly recommend upgrading to at least 2.4.1 because 2.4.0 contains a bug with content cards (see the changelog).
@wesleyorbin Thanks a lot for your super quick reply. I've tried this and looks like it works as expected now 🎉 . I'll test it a bit more this week in a release and if it's resolved I'll close this ticket by the end of this week if that's ok. Thanks again for your help! Out of interest are there any other useful API docs other than this one that I've been using? https://js.appboycdn.com/web-sdk/latest/doc/module-appboy.html
@kevinrodrigues The docs that you linked are the official API docs for the Web SDK. You can also check our integration guide or contact our our support team and they would be happy to help you with any integration issues.
Hi,
I seem to be having an issue with the method
getCachedContentCards
returning an empty array the very first time a user lands on a page (the second refresh is fine). I've narrowed it down to alocalStorage
valueab.storage.cc.[api-key]
that seems to be set to"{"v":[]}"
initially and then it gets populated but by that time thesync
has already happened. On second reload of the browser I get cards coming back fine because thelocalStorage
value mentioned is already in place from the first load.In terms of the rough implementation please see below, please also note that this is only an issue on mobile safari I've tried several iPhones on BrowserStack and this is the same issue across them all including actual physical devices. I did see an issue here that looks related and tried using the
appboy.subscribeToContentCardsUpdates()
in place of thegetCachedContentCards()
call below but it still doesn't work.There might be something really obvious that I've missed or left out here so please let me know and I'll try to provide that for you.