diff --git a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m index 698633aa67..e4f9ab037d 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m +++ b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m @@ -990,11 +990,14 @@ - (void)fetchServerConfiguration:(FBSDKCodeBlock)callback if ([self.settings isSKAdNetworkReportEnabled]) { [self.featureChecker checkFeature:FBSDKFeatureSKAdNetwork completionBlock:^(BOOL SKAdNetworkEnabled) { if (SKAdNetworkEnabled) { - if (@available(iOS 15.4, *)) { - [SKAdNetwork updatePostbackConversionValue:0 completionHandler:nil]; - } else { - // Fallback on earlier versions - [SKAdNetwork registerAppForAdNetworkAttribution]; + if (![self.primaryDataStore fb_boolForKey:@"com.facebook.sdk:FBSDKIsSkAdNetworkInstallReported"]) { + if (@available(iOS 15.4, *)) { + [SKAdNetwork updatePostbackConversionValue:0 completionHandler:nil]; + } else { + // Fallback on earlier versions + [SKAdNetwork registerAppForAdNetworkAttribution]; + } + [self.primaryDataStore fb_setBool:true forKey:@"com.facebook.sdk:FBSDKIsSkAdNetworkInstallReported"]; } [self.featureChecker checkFeature:FBSDKFeatureSKAdNetworkConversionValue completionBlock:^(BOOL SKAdNetworkConversionValueEnabled) { if (SKAdNetworkConversionValueEnabled) { diff --git a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/SKAdNetwork/FBSDKSKAdNetworkReporter.m b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/SKAdNetwork/FBSDKSKAdNetworkReporter.m index ac4d932c79..f6927fa082 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/SKAdNetwork/FBSDKSKAdNetworkReporter.m +++ b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/SKAdNetwork/FBSDKSKAdNetworkReporter.m @@ -68,12 +68,6 @@ - (void)enable if (@available(iOS 14.0, *)) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - if (@available(iOS 15.4, *)) { - [SKAdNetwork updatePostbackConversionValue:0 completionHandler:nil]; - } else { - // Fallback on earlier versions - [SKAdNetwork registerAppForAdNetworkAttribution]; - } [self _loadReportData]; self.completionBlocks = [NSMutableArray new]; self.serialQueue = dispatch_queue_create(serialQueueLabel, DISPATCH_QUEUE_SERIAL); diff --git a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/Helpers/TestDataStore.swift b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/Helpers/TestDataStore.swift index 3812d404c0..cb0c8ebbaf 100644 --- a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/Helpers/TestDataStore.swift +++ b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/Helpers/TestDataStore.swift @@ -7,11 +7,13 @@ */ final class TestDataStore: DataPersisting { + func fb_setBool(_ value: Bool, forKey defaultName: String) {} func fb_setInteger(_ value: Int, forKey defaultName: String) {} func fb_setObject(_ value: Any, forKey defaultName: String) {} func fb_data(forKey defaultName: String) -> Data? { nil } func fb_integer(forKey defaultName: String) -> Int { Int.min } func fb_string(forKey defaultName: String) -> String? { nil } func fb_object(forKey defaultName: String) -> Any? { nil } + func fb_bool(forKey defaultName: String) -> Bool { false } func fb_removeObject(forKey defaultName: String) {} } diff --git a/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/NSUserDefaults+NSUserDefaults_FBSDKDataPersisting.m b/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/NSUserDefaults+NSUserDefaults_FBSDKDataPersisting.m index ddac1e7749..365e3bc153 100644 --- a/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/NSUserDefaults+NSUserDefaults_FBSDKDataPersisting.m +++ b/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/NSUserDefaults+NSUserDefaults_FBSDKDataPersisting.m @@ -48,6 +48,18 @@ - (nullable NSData *)fb_dataForKey:(NSString *)key return [self dataForKey:key]; } +- (BOOL)fb_boolForKey:(NSString *)key +{ + return [self boolForKey:key]; +} + +- (void)fb_setBool:(BOOL)value + forKey:(NSString *)key +{ + [self setBool:value forKey:key]; +} + + - (void)fb_removeObjectForKey:(NSString *)key { [self removeObjectForKey:key]; diff --git a/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/include/FBSDKDataPersisting.h b/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/include/FBSDKDataPersisting.h index fbcccfadd8..6e6bab8c1d 100644 --- a/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/include/FBSDKDataPersisting.h +++ b/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/include/FBSDKDataPersisting.h @@ -24,6 +24,8 @@ NS_SWIFT_NAME(DataPersisting) - (NSInteger)fb_integerForKey:(NSString *)key; - (nullable NSString *)fb_stringForKey:(NSString *)key; - (nullable id)fb_objectForKey:(NSString *)key; +- (BOOL)fb_boolForKey:(NSString *)key; +- (void)fb_setBool:(BOOL)value forKey:(NSString *)key; - (void)fb_removeObjectForKey:(NSString *)key; @end