mirror of
https://github.com/zhigang1992/facebook-ios-sdk.git
synced 2026-01-12 17:22:28 +08:00
Fix duplicate install issue
Summary: There exists a potential issue that duplicate install can be sent because `applicationDidBecomeActive` may be triggered multiple times within a very short time (e.g. App Launch and ATT prompt can trigger this function) and thus cause `publichInstall` is triggered multiple times. In order to fix this issue, this diff reuses the existing key `lastAttributionPingString` and `lastInstallResponseKey`. The flow will be 1. PublishInstall is triggered 2. Check if `lastAttributionPingString` exists and will send install event and set the key if the key doesn't exist. We do nothing if the key exists. 3. If the install event is sent successfully, we will set the key `lastInstallResponseKey`. If not, we'll remove the key `lastAttributionPingString`. 4. When app terminates, we'll check if `lastInstallResponseKey` exists to check if the install event is sent successfully. If the key exists, we'll do nothing. If the key doesn't exist, it means the install event is not sent successfully in the app launch and we'll remove the key `lastAttributionPingString`. Reviewed By: jjiang10 Differential Revision: D53170017 fbshipit-source-id: 340e21188d884088215a65d06fffc402065a5102
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2dc3ba59a4
commit
272bff5cd6
@@ -12,6 +12,7 @@ import Foundation
|
||||
public final class UserDefaultsSpy: UserDefaults {
|
||||
public var capturedObjectRetrievalKeys = [String]()
|
||||
public var capturedSetObjectKeys = [String]()
|
||||
public var capturedRemoveObjectKeys = [String]()
|
||||
public var capturedObjectRetrievalKey: String?
|
||||
public var capturedSetObjectKey: String?
|
||||
public var capturedValues = [String: Any]()
|
||||
@@ -33,4 +34,8 @@ public final class UserDefaultsSpy: UserDefaults {
|
||||
capturedSetObjectKeys.append(defaultName)
|
||||
capturedSetObjectKey = defaultName
|
||||
}
|
||||
|
||||
public override func removeObject(forKey defaultName: String) {
|
||||
capturedRemoveObjectKeys.append(defaultName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user