Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
Summary: This diff fixes some minor edge cases realized from testing.

Reviewed By: maxalbrightmeta

Differential Revision: D67967906

fbshipit-source-id: 913b83593859da5c81a1b4a19a8c73edfef9baa0
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Jan 9, 2025
1 parent 68063c2 commit adf4730
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
FBSDKAppEventParameterName const FBSDKAppEventParameterNameProductTitle = @"fb_content_title";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameTransactionID = @"fb_transaction_id";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameTransactionDate = @"fb_transaction_date";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameOriginalTransactionID = @"fb_original_transaction_id";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameOriginalTransactionDate = @"fb_original_transaction_date";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameSubscriptionPeriod = @"fb_iap_subs_period";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameIsStartTrial = @"fb_iap_is_start_trial";
FBSDKAppEventParameterName const FBSDKAppEventParameterNameHasFreeTrial = @"fb_iap_has_free_trial";
Expand Down
1 change: 1 addition & 0 deletions FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ - (void)fetchServerConfiguration:(FBSDKCodeBlock)callback
}];
} else {
[self.iapDedupeProcessor disable];
[self.transactionObserver stopObserving];
[self.paymentObserver startObservingTransactions];
}
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extension IAPTransactionLogger {
private func getOperationalParameters(for event: IAPEvent) -> [AppOperationalDataType: [String: Any]] {
var iapParameters = [String: Any]()
let transactionDate = event.transactionDate.map { dateFormatter.string(from: $0) } ?? ""
let originalTransactionDate = event.originalTransactionDate.map { dateFormatter.string(from: $0) } ?? ""
let consumablesInPurchaseHistory =
Bundle.main.fb_object(forInfoDictionaryKey: IAPConstants.consumablesInPurchaseHistoryKey) as? Bool ?? false
iapParameters = [
Expand All @@ -116,6 +117,10 @@ extension IAPTransactionLogger {
if let transactionID = event.transactionID {
iapParameters[AppEvents.ParameterName.transactionID.rawValue] = transactionID
}
if let originalTransactionID = event.originalTransactionID {
iapParameters[AppEvents.ParameterName.originalTransactionID.rawValue] = originalTransactionID
}
iapParameters[AppEvents.ParameterName.originalTransactionDate.rawValue] = originalTransactionDate
if event.isClientSideVerifiable {
let validationResult = event.validationResult?.rawValue ?? IAPValidationResult.unverified.rawValue
iapParameters[AppEvents.ParameterName.validationResult.rawValue] = validationResult
Expand Down Expand Up @@ -204,7 +209,6 @@ extension IAPTransactionLogger {
private func logRestoredEvent(_ event: IAPEvent) {
if IAPTransactionCache.shared.contains(
transactionID: event.originalTransactionID,
eventName: event.eventName,
productID: event.productID
) {
return
Expand Down
5 changes: 5 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/ApplicationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ public final class ApplicationDelegate: NSObject {
applicationObservers.allObjects.forEach { observer in
observer.applicationDidBecomeActive?(notification?.object as? UIApplication)
}
if #available(iOS 15.0, *) {
Task {
await IAPTransactionObserver.shared.observeNewTransactions()
}
}
}

func applicationWillResignActive(_ notification: Notification) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ FOUNDATION_EXPORT FBSDKAppEventParameterName const FBSDKAppEventParameterNameIAP
FOUNDATION_EXPORT FBSDKAppEventParameterName const FBSDKAppEventParameterNameProductClassification;

FOUNDATION_EXPORT FBSDKAppEventParameterName const FBSDKAppEventParameterNameConsumablesInPurchaseHistory;

FOUNDATION_EXPORT FBSDKAppEventParameterName const FBSDKAppEventParameterNameOriginalTransactionID;

FOUNDATION_EXPORT FBSDKAppEventParameterName const FBSDKAppEventParameterNameOriginalTransactionDate;
Original file line number Diff line number Diff line change
Expand Up @@ -1739,9 +1739,9 @@ final class AppEventsTests: XCTestCase {
transactionObserver.didStartObserving,
"fetchConfiguration should not start transaction observing if the configuration allows it and SK2 is disabled"
)
XCTAssertFalse(
XCTAssertTrue(
transactionObserver.didStopObserving,
"fetchConfiguration should not stop transaction observing if the configuration allows it"
"fetchConfiguration should stop transaction observing if the configuration disallows it"
)
}

Expand Down

0 comments on commit adf4730

Please sign in to comment.