Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Firebase/InAppMessaging/Flows/FIRIAMFetchFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#import "FIRIAMActivityLogger.h"
#import "FIRIAMBookKeeper.h"
#import "FIRIAMDisplayExecutor.h"
#import "FIRIAMMessageClientCache.h"
#import "FIRIAMSDKModeManager.h"
#import "FIRIAMTimeFetcher.h"
Expand Down Expand Up @@ -50,7 +51,8 @@ typedef void (^FIRIAMFetchMessageCompletionHandler)(
bookKeeper:(id<FIRIAMBookKeeper>)displayBookKeeper
activityLogger:(FIRIAMActivityLogger *)activityLogger
analyticsEventLogger:(id<FIRIAMAnalyticsEventLogger>)analyticsEventLogger
FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager;
FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager
displayExecutor:(FIRIAMDisplayExecutor *)displayExecutor;

// Triggers a potential fetch of in-app messaging from the source. It would check and respect the
// the fetchMinIntervalInMinutes defined in setting
Expand Down
10 changes: 6 additions & 4 deletions Firebase/InAppMessaging/Flows/FIRIAMFetchFlow.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ @interface FIRIAMFetchFlow ()
@property(nonatomic, nonnull, readonly) id<FIRIAMBookKeeper> fetchBookKeeper;
@property(nonatomic, nonnull, readonly) FIRIAMActivityLogger *activityLogger;
@property(nonatomic, nonnull, readonly) id<FIRIAMAnalyticsEventLogger> analyticsEventLogger;

@property(nonatomic, nonnull, readonly) FIRIAMSDKModeManager *sdkModeManager;
@property(nonatomic, nonnull, readonly) FIRIAMDisplayExecutor *displayExecutor;

@end

@implementation FIRIAMFetchFlow
Expand All @@ -48,7 +49,8 @@ - (instancetype)initWithSetting:(FIRIAMFetchSetting *)setting
bookKeeper:(id<FIRIAMBookKeeper>)fetchBookKeeper
activityLogger:(FIRIAMActivityLogger *)activityLogger
analyticsEventLogger:(id<FIRIAMAnalyticsEventLogger>)analyticsEventLogger
FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager {
FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager
displayExecutor:(FIRIAMDisplayExecutor *)displayExecutor {
if (self = [super init]) {
_timeFetcher = timeFetcher;
_lastFetchTime = [fetchBookKeeper lastFetchTime];
Expand All @@ -59,6 +61,7 @@ - (instancetype)initWithSetting:(FIRIAMFetchSetting *)setting
_activityLogger = activityLogger;
_analyticsEventLogger = analyticsEventLogger;
_sdkModeManager = sdkModeManager;
_displayExecutor = displayExecutor;
}
return self;
}
Expand Down Expand Up @@ -257,7 +260,6 @@ - (void)checkAndFetchForInitialAppLaunch:(BOOL)forInitialAppLaunch {
}

- (void)checkForAppLaunchMessage {
[[FIRIAMRuntimeManager getSDKRuntimeInstance]
.displayExecutor checkAndDisplayNextAppLaunchMessage];
[self.displayExecutor checkAndDisplayNextAppLaunchMessage];
}
@end
21 changes: 11 additions & 10 deletions Firebase/InAppMessaging/Runtime/FIRIAMRuntimeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,6 @@ - (void)internalStartRuntimeWithSDKSettings:(FIRIAMSDKSettings *)settings {
[[FIRIAMSDKModeManager alloc] initWithUserDefaults:NSUserDefaults.standardUserDefaults
testingModeListener:self];

self.fetchOnAppForegroundFlow =
[[FIRIAMFetchOnAppForegroundFlow alloc] initWithSetting:fetchSetting
messageCache:self.messageCache
messageFetcher:self.restfulFetcher
timeFetcher:timeFetcher
bookKeeper:self.bookKeeper
activityLogger:self.activityLogger
analyticsEventLogger:analyticsEventLogger
FIRIAMSDKModeManager:sdkModeManager];

FIRIAMActionURLFollower *actionFollower = [FIRIAMActionURLFollower actionURLFollower];

self.displayExecutor =
Expand All @@ -347,6 +337,17 @@ - (void)internalStartRuntimeWithSDKSettings:(FIRIAMSDKSettings *)settings {
activityLogger:self.activityLogger
analyticsEventLogger:analyticsEventLogger];

self.fetchOnAppForegroundFlow =
[[FIRIAMFetchOnAppForegroundFlow alloc] initWithSetting:fetchSetting
messageCache:self.messageCache
messageFetcher:self.restfulFetcher
timeFetcher:timeFetcher
bookKeeper:self.bookKeeper
activityLogger:self.activityLogger
analyticsEventLogger:analyticsEventLogger
FIRIAMSDKModeManager:sdkModeManager
displayExecutor:self.displayExecutor];

// Setting the message display component and suppression. It's needed in case
// headless SDK is initialized after the these properties are already set on FIRInAppMessaging.
self.displayExecutor.messageDisplayComponent =
Expand Down
2 changes: 1 addition & 1 deletion InAppMessaging/Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ target 'InAppMessaging_Tests_iOS' do
pod 'FirebaseInAppMessaging', :path => '../..'
pod 'FirebaseInstanceID', :path => '../..'
pod 'FirebaseAnalyticsInterop', :path => '../..'
pod 'OCMock', '~> 3.4.0'
pod 'OCMock'
end
7 changes: 5 additions & 2 deletions InAppMessaging/Example/Tests/FIRIAMFetchFlowTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ @interface FIRIAMFetchFlowTests : XCTestCase
@property FIRIAMFetchFlow *flow;
@property FIRIAMActivityLogger *activityLogger;
@property FIRIAMSDKModeManager *mockSDKModeManager;
@property FIRIAMDisplayExecutor *mockDisplayExecutor;

@property id<FIRIAMAnalyticsEventLogger> mockAnaltycisEventLogger;

Expand Down Expand Up @@ -159,6 +160,7 @@ - (void)setUp {
self.mockSDKModeManager = OCMClassMock([FIRIAMSDKModeManager class]);

self.mockTimeFetcher = OCMProtocolMock(@protocol(FIRIAMTimeFetcher));
self.mockDisplayExecutor = OCMClassMock([FIRIAMDisplayExecutor class]);

self.flow = [[FIRIAMFetchFlow alloc] initWithSetting:self.fetchSetting
messageCache:self.clientMessageCache
Expand All @@ -167,7 +169,8 @@ - (void)setUp {
bookKeeper:self.mockBookkeeper
activityLogger:self.activityLogger
analyticsEventLogger:self.mockAnaltycisEventLogger
FIRIAMSDKModeManager:self.mockSDKModeManager];
FIRIAMSDKModeManager:self.mockSDKModeManager
displayExecutor:self.mockDisplayExecutor];
}

- (void)tearDown {
Expand Down Expand Up @@ -276,7 +279,7 @@ - (void)testAlwaysFetchForNewlyInstalledMode {
OCMVerify([self.mockSDKModeManager registerOneMoreFetch]);

// we expect that the message cache is checked for app launch messages
OCMVerify([self.flow checkForAppLaunchMessage]);
OCMVerify([self.mockDisplayExecutor checkAndDisplayNextAppLaunchMessage]);
}

// Fetch always in testing app instance mode
Expand Down