-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
[REQUIRED] Step 1: Describe your environment
- Xcode version: 13.1
- Firebase SDK version: 8.10.0
- Installation method:
Swift Package Manager
- Firebase Component: In-App Messaging
- Target platform(s):
iOS
[REQUIRED] Step 2: Describe the problem
Duplicate messages can occur when two campaigns are triggered by different events. (The first message must have an image to reproduce it.)
Setup like this in the console.
First Event | Second Event |
---|---|
![]() |
![]() |
And trigger events consecutively like this code.
struct ContentView: View {
var body: some View {
Button("Trigger In-App") {
InAppMessaging.inAppMessaging().triggerEvent("first_event")
InAppMessaging.inAppMessaging().triggerEvent("second_event")
}
.padding()
}
}
It shows multiple dialogs in a row.
2021-12-09.23.03.34.mov
It seems FIRIAMDisplayExecutor checks message is displayed or not in this code.
firebase-ios-sdk/FirebaseInAppMessaging/Sources/Flows/FIRIAMDisplayExecutor.m
Lines 422 to 428 in c7f80c1
if (self.isMsgBeingDisplayed) { | |
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM400008", | |
@"An in-app message display is in progress, do not check analytics event " | |
"based message for now."); | |
return; | |
} |
However, isMsgBeingDisplayed
becomes true only after the image has finished loading.
self.isMsgBeingDisplayed = YES; |
I think if another event is triggered while loading the image in a first event, two dialogs are shown in the order in which the images were loaded.
And _currentMsgBeingDisplayed
is set as last called displayForMessage
. The last event(In this video, second event) may be treated as displayed.
firebase-ios-sdk/FirebaseInAppMessaging/Sources/Flows/FIRIAMDisplayExecutor.m
Lines 317 to 336 in c7f80c1
- (void)recordValidImpression:(NSString *)messageID withMessageName:(NSString *)messageName { | |
if (!self.impressionRecorded) { | |
[self.displayBookKeeper | |
recordNewImpressionForMessage:messageID | |
withStartTimestampInSeconds:[self.timeFetcher currentTimestampInSeconds]]; | |
self.impressionRecorded = YES; | |
[self.messageCache removeMessageWithId:messageID]; | |
// Log an impression analytics event as well. | |
[self.analyticsEventLogger | |
logAnalyticsEventForType:FIRIAMAnalyticsEventMessageImpression | |
forCampaignID:messageID | |
withCampaignName:messageName | |
eventTimeInMs:nil | |
completion:^(BOOL success) { | |
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM400007", | |
@"Logging analytics event for impression %@", | |
success ? @"succeeded" : @"failed"); | |
}]; | |
} | |
} |
Therefore, on the second tap in this video, it shows the first event.
I think the first tap will give me a first event message, and the second tap will give me a second event message.
Steps to reproduce:
- Set two campaigns with another event trigger and it has an image.
- Trigger events consecutively.
Minimum reproduce project is here: https://github.com/kouki-dan/InAppMessaging-Duplicate