10BC0 Duplicate messages can occur when two campaigns are triggered by different events in In-App Messaging · Issue #9070 · firebase/firebase-ios-sdk · GitHub
[go: up one dir, main page]

Skip to content

Duplicate messages can occur when two campaigns are triggered by different events in In-App Messaging #9070

@kouki-dan

Description

@kouki-dan

[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
スクリーンショット 2021-12-09 23 07 04 スクリーンショット 2021-12-09 23 07 35

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.

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.

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.

- (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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0