Skip to content

Commit

Permalink
Updated Privacy Manifests and some unit tests
Browse files Browse the repository at this point in the history
Summary: Updated Privacy Manifests and some unit tests

Reviewed By: jjiang10

Differential Revision: D54685662

fbshipit-source-id: 4bf55d2e21adefe61677f97ea22ede0297e3de70
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Mar 11, 2024
1 parent e347cce commit af20a84
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 51 deletions.
4 changes: 3 additions & 1 deletion FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,9 @@ - (void)validateConfiguration
{
[self validateConfiguration];

accessToken = accessToken ?: FBSDKAccessToken.currentAccessToken;
if (accessToken == nil && (![[FBSDKDomainHandler sharedInstance] isDomainHandlingEnabled] || self.settings.isAdvertiserTrackingEnabled)) {
accessToken = FBSDKAccessToken.currentAccessToken;
}

// Rules for how we use the attribution ID / advertiser ID for an 'custom_audience_third_party_id' Graph API request
// 1) if the OS tells us that the user has Limited Ad Tracking, then just don't send, and return a nil in the token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,26 +373,30 @@ - (BOOL)validateIdentifier:(nullable NSString *)identifier
}

// Given a candidate token (which may be nil), find the real token to string to use.
// Precedence: 1) provided token, 2) current token, 3) app | client token, 4) fully anonymous session.
// Precedence: 1) provided token, 2) current token only if ATE is true, 3) app | client token, 4) fully anonymous session.
- (nullable NSString *)tokenStringToUseFor:(nullable FBSDKAccessToken *)token
loggingOverrideAppID:(nullable NSString *)loggingOverrideAppID
{
if (!token) {
if (!token && (![[FBSDKDomainHandler sharedInstance] isDomainHandlingEnabled] || self.settings.isAdvertiserTrackingEnabled)) {
token = FBSDKAccessToken.currentAccessToken;
}

if (token && token.isExpired) {
token = nil;
}

NSString *appID = loggingOverrideAppID ?: token.appID ?: self.settings.appID;
NSString *tokenString = token.tokenString;
NSString *clientTokenString = self.settings.clientToken;

if (![appID isEqualToString:token.appID]) {
if (!token || ![appID isEqualToString:token.appID]) {
// If there's a logging override app id present
// then we don't want to use the client token since the client token
// is intended to match up with the primary app id
// and AppEvents doesn't require a client token.
if (clientTokenString && loggingOverrideAppID) {
if (clientTokenString && loggingOverrideAppID && loggingOverrideAppID != self.settings.appID && loggingOverrideAppID != token.appID) {
tokenString = nil;
} else if (clientTokenString && appID && ([appID isEqualToString:token.appID] || token == nil)) {
} else if (clientTokenString && appID && (token == nil || [appID isEqualToString:token.appID])) {
tokenString = [NSString stringWithFormat:@"%@|%@", appID, clientTokenString];
} else if (appID) {
tokenString = nil;
Expand Down
7 changes: 4 additions & 3 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAccessToken.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ + (BOOL)supportsSecureCoding
- (instancetype)initWithCoder:(NSCoder *)decoder
{
NSString *appID = [decoder decodeObjectOfClass:NSString.class forKey:FBSDK_ACCESSTOKEN_APPID_KEY];
NSSet<NSString *> *declinedPermissions = [decoder decodeObjectOfClass:NSSet.class forKey:FBSDK_ACCESSTOKEN_DECLINEDPERMISSIONS_KEY];
NSSet<NSString *> *expiredPermissions = [decoder decodeObjectOfClass:NSSet.class forKey:FBSDK_ACCESSTOKEN_EXPIREDPERMISSIONS_KEY];
NSSet<NSString *> *permissions = [decoder decodeObjectOfClass:NSSet.class forKey:FBSDK_ACCESSTOKEN_PERMISSIONS_KEY];
NSSet<Class> *classes = [NSSet setWithArray:@[NSSet.class, NSString.class]];
NSSet<NSString *> *declinedPermissions = [decoder decodeObjectOfClasses:classes forKey:FBSDK_ACCESSTOKEN_DECLINEDPERMISSIONS_KEY];
NSSet<NSString *> *expiredPermissions = [decoder decodeObjectOfClasses:classes forKey:FBSDK_ACCESSTOKEN_EXPIREDPERMISSIONS_KEY];
NSSet<NSString *> *permissions = [decoder decodeObjectOfClasses:classes forKey:FBSDK_ACCESSTOKEN_PERMISSIONS_KEY];
NSString *tokenString = [decoder decodeObjectOfClass:NSString.class forKey:FBSDK_ACCESSTOKEN_TOKENSTRING_KEY];
NSString *userID = [decoder decodeObjectOfClass:NSString.class forKey:FBSDK_ACCESSTOKEN_USERID_KEY];
NSDate *refreshDate = [decoder decodeObjectOfClass:NSDate.class forKey:FBSDK_ACCESSTOKEN_REFRESHDATE_KEY];
Expand Down
7 changes: 6 additions & 1 deletion FBSDKCoreKit/FBSDKCoreKit/FBSDKInternalUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,12 @@ - (void)detectFatalTrackingDomainsConfig
@"Frameworks/FBSDKCoreKit_Basics.framework",
@"Frameworks/FBAEMKit.framework",
@"Frameworks/FBSDKLoginKit.framework",
@"Frameworks/FBSDKShareKit.framework"];
@"Frameworks/FBSDKShareKit.framework",
@"Facebook_FacebookAEM.bundle",
@"Facebook_FacebookBasics.bundle",
@"Facebook_FacebookCore.bundle",
@"Facebook_FacebookLogin.bundle",
@"Facebook_FacebookShare.bundle"];
for (NSString *subdirectory in subdirectories) {
NSString *subdir = [subdirectory isKindOfClass:[NSNull class]] ? nil: subdirectory;
NSArray<NSURL *> *privacyInfoUrls = [[NSBundle mainBundle] URLsForResourcesWithExtension:@"xcprivacy" subdirectory:subdir];
Expand Down
5 changes: 3 additions & 2 deletions FBSDKCoreKit/FBSDKCoreKit/GraphAPI/FBSDKGraphRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,14 @@ - (BOOL)hasAttachments
+ (BOOL)isForFetchingDomainConfiguration:(id<FBSDKGraphRequest>)request
{
NSString *appID = self.class.settings.appID;
if (![request.graphPath isEqualToString:appID]) {
NSString *expectedGraphPath = [NSString stringWithFormat:@"%@/%@", appID, kDomainConfigurationDomainInfoField];
if (![request.graphPath isEqualToString:expectedGraphPath]) {
return NO;
}
if (![request.HTTPMethod isEqualToString:FBSDKHTTPMethodGET]) {
return NO;
}
if (!request.parameters || ![[request.parameters objectForKey:@"fields"] isEqualToString:kDomainConfigurationDomainInfoField]) {
if (!request.parameters || ![[request.parameters objectForKey:@"fields"] isEqualToString:@""]) {
return NO;
}
return YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ - (void)processLoadRequestResponse:(id)result error:(nullable NSError *)error

- (id<FBSDKGraphRequest>)requestToLoadDomainConfiguration:(NSString *)appID
{
NSDictionary<NSString *, NSString *> *parameters = @{ @"fields" : DOMAIN_CONFIGURATION_DOMAIN_INFO_FIELD };

return [self.graphRequestFactory createGraphRequestWithGraphPath:appID
NSDictionary<NSString *, NSString *> *parameters = @{ @"fields" : @"" };
NSString *graphPath = [NSString stringWithFormat:@"%@/%@", appID, DOMAIN_CONFIGURATION_DOMAIN_INFO_FIELD];
return [self.graphRequestFactory createGraphRequestWithGraphPath:graphPath
parameters:parameters
tokenString:nil
HTTPMethod:nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
[NSDictionary<NSString *, id> class],
NSString.class,
NSArray.class,
NSNumber.class,
nil];
NSArray<NSDictionary<NSString *, id> *> *eventBindings = [decoder decodeObjectOfClasses:eventBindingsClasses forKey:FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS];
NSSet<Class> *dictionaryClasses = [NSSet setWithObjects:
Expand Down
12 changes: 12 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDataTypes</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
Expand Down
10 changes: 10 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ public final class Settings: NSObject, SettingsProtocol, SettingsLogging, _Clien
*/
public var isAdvertiserTrackingEnabled: Bool {
get { advertisingTrackingStatus == .allowed }

@available(
*,
deprecated,
message: """
The setAdvertiserTrackingEnabled flag is not used for FBSDK v17+ on iOS 17+ \
as the FBSDK v17+ now relies on ATTrackingManager.trackingAuthorizationStatus \
to accurately represent ATT permission for users of your app.
"""
)
set(isNewlyAllowed) {
if _DomainHandler.sharedInstance().isDomainHandlingEnabled() {
// swiftlint:disable:next line_length
Expand Down
4 changes: 2 additions & 2 deletions FBSDKCoreKit/FBSDKCoreKitTests/DomainHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ final class DomainHandlerTests: XCTestCase {
XCTFail("Should have an app id")
return
}
let parameters = ["fields": "server_domain_infos"]
let domainConfigRequest = GraphRequest(graphPath: appID, parameters: parameters, httpMethod: .get)
let parameters = ["fields": ""]
let domainConfigRequest = GraphRequest(graphPath: "\(appID)/server_domain_infos", parameters: parameters, httpMethod: .get)
let urlPrefix = _DomainHandler.sharedInstance().getURLPrefix(
forSingleRequest: domainConfigRequest,
isAdvertiserTrackingEnabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ final class GraphRequestConnectionTests: XCTestCase, GraphRequestConnectionDeleg
return
}
GraphRequestConnection.resetDidFetchDomainConfiguration()
let parameters = ["fields": "server_domain_infos"]
let domainConfigRequest = GraphRequest(graphPath: appID, parameters: parameters, httpMethod: .get)
let parameters = ["fields": ""]
let domainConfigRequest = GraphRequest(graphPath: "\(appID)/server_domain_infos", parameters: parameters, httpMethod: .get)
connection.add(domainConfigRequest) { _, _, _ in }
connection.start()
XCTAssertEqual(
Expand Down Expand Up @@ -2054,8 +2054,8 @@ final class GraphRequestConnectionTests: XCTestCase, GraphRequestConnectionDeleg
}

func testShouldPiggyBackDomainConfigurationRequest() {
let parameters = ["fields": "server_domain_infos"]
let domainConfigRequest = GraphRequest(graphPath: appID, parameters: parameters, httpMethod: .get)
let parameters = ["fields": ""]
let domainConfigRequest = GraphRequest(graphPath: "\(appID)/server_domain_infos", parameters: parameters, httpMethod: .get)
connection.add(domainConfigRequest) { _, _, _ in }
if #available(iOS 14.5, *) {
XCTAssertFalse(
Expand Down
10 changes: 5 additions & 5 deletions FBSDKCoreKit/FBSDKCoreKitTests/GraphRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ final class GraphRequestTests: XCTestCase {
XCTFail("Should have an app id")
return
}
let parameters = ["fields": "server_domain_infos"]
let parameters = ["fields": ""]
let domainConfigRequest1 = graphRequestFactory.createGraphRequest(
withGraphPath: appID,
withGraphPath: "\(appID)/server_domain_infos",
parameters: parameters,
tokenString: nil,
httpMethod: nil,
Expand All @@ -474,7 +474,7 @@ final class GraphRequestTests: XCTestCase {
"Request is for fetching the domain configuration"
)

let domainConfigRequest2 = GraphRequest(graphPath: appID, parameters: parameters, httpMethod: .get)
let domainConfigRequest2 = GraphRequest(graphPath: "\(appID)/server_domain_infos", parameters: parameters, httpMethod: .get)
XCTAssertTrue(
GraphRequest.isForFetchingDomainConfiguration(request: domainConfigRequest2),
"Request is for fetching the domain configuration"
Expand Down Expand Up @@ -505,8 +505,8 @@ final class GraphRequestTests: XCTestCase {
)

let failingRequest5 = GraphRequest(
graphPath: appID,
parameters: ["fields": "server_domain_infos,test_field,name,app_events_feature_bitmask"],
graphPath: "\(appID)/server_domain_infos",
parameters: ["fields": "test_field,name,app_events_feature_bitmask"],
httpMethod: .get
)
XCTAssertFalse(
Expand Down
Loading

0 comments on commit af20a84

Please sign in to comment.