1

After updating the MarketingCloudSDK from 7.1.0 to 7.4.0, sfmc_refreshMessages() always return false. Until V7.1.0 sfmc_refreshMessages() use to return true if cloud server had new messages or when called after an interval of 60 seconds.

  1. How do we know if server has new messages & we should wait for notifications (SFMCInboxMessagesNewInboxMessages or SFMCInboxMessagesRefreshComplete) to be triggered?

V7.1.0 Current implementation, when sfmc_refreshMessages() is true we wait for SFMCInboxMessagesRefreshComplete & SFMCInboxMessagesNewInboxMessages notifications to be triggered and then we call sfmc_getAllMessages() to get the latest array of messages.

After updating to V7.4.0 sfmc_refreshMessages() is always false. SFMCInboxMessagesRefreshComplete & SFMCInboxMessagesNewInboxMessages are triggered if new messages are available but how do we decide whether to wait for these notifications or load the data through sfmc_getAllMessages() immediately?

Any help is much appreciated.

1 Answer 1

2

Great question. The SDK has always used a 60 second inbox refresh rate limiter. This is a common practice to manage spamming of backend services. The result of the v7.4.0 release is to accurately notify through sfmc_refreshMessages() method if the SDK made a request to refresh the messages or not.

First, one thing to understand about the SDK is to note that the SDK (in both versions mentioned above) will automatically request to refresh messages from the server on app foreground/launch. This is done free for you in order to optimize having fresh data each time a user comes into the app.

For example, if you launch the app and immediately call sfmc_refreshMessages(), you will notice that the method will return FALSE as the request to load messages from the server has already been made by the SDK for you during the foregrounding/launching of the app. You can of course still listen for the SFMCInboxMessagesRefreshComplete & SFMCInboxMessagesNewInboxMessages notifications as that will tell you when a successful load from the server has occurred. Every subsequent call to sfmc_refreshMessages() will result in a TRUE result only if the SDK has not previously made a call in the last 60 seconds.

Bottom line: If you call sfmc_refreshMessages() within 60 seconds of launching/foregrounding the app or a previous call, you will expect to see a FALSE return as the data is less than 60 seconds old. Then, after 60 seconds of being in the app without a launch/foreground event, or a call to sfmc_refreshMessages(), you will get a TRUE response as the data is now older than 60 seconds and the call to refresh from the server was made. You will be able to verify this behavior when you enable logging in the SDK and read the output after your sfmc_refreshMessages() calls.

6
  • Thank you very much for the detailed explanation. It does answer a lot of my queries. We have a usecase were-in when user taps on a notification (Alert+Inbox) we fetch all the messages through sfmc_getAllMessages() and look for the message corresponding to the notification which user has tapped & mark it as read. Assuming an edge case - User in on Inbox listing page (we call sfmc_getAllMessages() & populate data in a TableView), at the same time he receives a Inbox push notification & he taps on it. sfmc_refreshMessages() will return false as last call was made < 60 sec ago.
    – Developer
    Mar 18, 2021 at 5:11
  • Now when I look for the message which user has tapped on in the local object returned by the SDK, it wont have the latest message. 1. How do we handle this scenario? 2. Is there a way for us to know when the last sync was made to the SFMC server? 3. How do we decide whether to wait for the notifications (refreshComplete) to be triggered or load data from the local object returned?
    – Developer
    Mar 18, 2021 at 5:14
  • Great use case. When the SDK receives a message it automatically stores it locally for you if you pass it to the SDK via MarketingCloudSDK.sharedInstance().sfmc_setNotificationRequest(response.notification.request) via Apple's provided delegate method userNotificationCenterDidReceiveResponse. With this implementation, after a message is opened by a user, the next time you ask for all the messages you will see that new message in the list. To optimize this you can also inspect the payload and call sfmc_markMessageWithIdRead when the message comes into the App. Mar 19, 2021 at 15:25
  • Ok, I’ll try this approach. In order to mark message as read, we require messageid which is not present in the notification payload. Then how do we mark the message as read without traversing the entire list.
    – Developer
    Mar 19, 2021 at 15:45
  • I tried setting .sfmc_setNotificationRequest(response.notification.request) in userNotificationCenterDidReceiveResponse. But it didnt solved my use case. When I call sfmc_refreshMessages (value is false) followed by sfmc_getAllMessages, I dont get the latest message in the list.
    – Developer
    Mar 25, 2021 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .