From 26ee2de4900d6174c992b434b9bb7713fb09e46d Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Mon, 30 Oct 2023 19:29:33 +0530 Subject: [PATCH] fix: Loading cached user data before IAM sdk initialization (SDKCF-6826) --- CHANGELOG.md | 4 ++-- Sources/RInAppMessaging/InAppMessagingModule.swift | 3 +++ Tests/Tests/InAppMessagingModuleSpec.swift | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f006517..7ac45c2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,12 @@ - Added device_id to DisplayPermission request header [SDKCF-6624] - Prevent calling `configure()` then RMC module is integrated [SDKCF-6710] - Added rmcsdk version parameter to all api calls [SDKCF-6709] - - Retaining API calls until configure() is called [SDKCF-6812] - Improvements: - - Retaining API calls until `configure()` is called [SDKCF-6740] + - Retaining API calls until `configure()` is called [SDKCF-6812] - Fixes: - Fixed Xcode 15 beta errors [SDKCF-6692] - Fixed Finding RMC Bundle [SDKCF-6751] + - Fixed Loading cached user data before IAM initialisation [SDKCF-6826] ### 8.0.0 (2023-06-21) - **Breaking changes:** diff --git a/Sources/RInAppMessaging/InAppMessagingModule.swift b/Sources/RInAppMessaging/InAppMessagingModule.swift index cbd7c72e..b0e5dbaf 100644 --- a/Sources/RInAppMessaging/InAppMessagingModule.swift +++ b/Sources/RInAppMessaging/InAppMessagingModule.swift @@ -93,6 +93,9 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, accountRepository.setPreference(preference) guard isInitialized else { + if accountRepository.updateUserInfo() { + campaignRepository.loadCachedData() + } return } diff --git a/Tests/Tests/InAppMessagingModuleSpec.swift b/Tests/Tests/InAppMessagingModuleSpec.swift index 556f9249..143fd2cc 100644 --- a/Tests/Tests/InAppMessagingModuleSpec.swift +++ b/Tests/Tests/InAppMessagingModuleSpec.swift @@ -304,9 +304,9 @@ class InAppMessagingModuleSpec: QuickSpec { expect(accountRepository.userInfoProvider).to(beIdenticalTo(aUser)) } - it("will not call checkUserChanges()") { + it("will call updateUserInfo() to update cached user data") { iamModule.registerPreference(aUser) - expect(accountRepository.wasUpdateUserInfoCalled).to(beFalse()) + expect(accountRepository.wasUpdateUserInfoCalled).to(beTrue()) } } }