Skip to content

Commit

Permalink
Correct type definition for UserIdentifier
Browse files Browse the repository at this point in the history
Reviewed By: joesus

Differential Revision: D37152498

fbshipit-source-id: 3426e5d2419b6cfed77213b9e38e3246a146793f
  • Loading branch information
samodom authored and facebook-github-bot committed Jun 14, 2022
1 parent e10ae83 commit 189920c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Made `AccessToken.currentAccessToken` use a Swift name of `current`.
- Made `AuthenticationToken.currentAuthenticationToken` use a Swift name of `current`.
- Renamed `SharingValidation` protocol to `SharingValidatable`.
- Corrected type definition for `FBSDKUserIdentifier` to be `NSString *` instead of `NSString` for Swift compatibility.

[2022-06-03](https://github.com/facebook/facebook-ios-sdk/releases/tag/v14.0.0) |
[Full Changelog](https://github.com/facebook/facebook-ios-sdk/compare/v13.2.0...v14.0.0)
Expand Down
38 changes: 19 additions & 19 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ + (void)setUrlHoster:(nullable id<FBSDKURLHosting>)urlHoster
_urlHoster = urlHoster;
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -124,7 +124,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
gender:nil];
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -151,7 +151,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
gender:nil];
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -160,7 +160,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
refreshDate:(nullable NSDate *)refreshDate
imageURL:(NSURL *)imageURL
email:(NSString *)email
friendIDs:(NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(NSArray<FBSDKUserIdentifier> *)friendIDs
{
return [self initWithUserID:userID
firstName:firstName
Expand All @@ -179,7 +179,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
gender:nil];
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -188,7 +188,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
refreshDate:(nullable NSDate *)refreshDate
imageURL:(NSURL *)imageURL
email:(NSString *)email
friendIDs:(NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(NSDate *)birthday
ageRange:(FBSDKUserAgeRange *)ageRange
{
Expand All @@ -209,7 +209,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
gender:nil];
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -218,7 +218,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
refreshDate:(nullable NSDate *)refreshDate
imageURL:(NSURL *)imageURL
email:(NSString *)email
friendIDs:(NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(NSDate *)birthday
ageRange:(FBSDKUserAgeRange *)ageRange
isLimited:(BOOL)isLimited
Expand All @@ -241,7 +241,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
isLimited:isLimited];
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -250,7 +250,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
refreshDate:(nullable NSDate *)refreshDate
imageURL:(nullable NSURL *)imageURL
email:(nullable NSString *)email
friendIDs:(nullable NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(nullable NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(nullable NSDate *)birthday
ageRange:(nullable FBSDKUserAgeRange *)ageRange
hometown:(nullable FBSDKLocation *)hometown
Expand Down Expand Up @@ -278,7 +278,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
return self;
}

- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -287,7 +287,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
refreshDate:(nullable NSDate *)refreshDate
imageURL:(NSURL *)imageURL
email:(NSString *)email
friendIDs:(NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(NSDate *)birthday
ageRange:(FBSDKUserAgeRange *)ageRange
hometown:(FBSDKLocation *)hometown
Expand Down Expand Up @@ -449,7 +449,7 @@ + (BOOL)supportsSecureCoding

- (instancetype)initWithCoder:(NSCoder *)decoder
{
FBSDKUserIdentifier *userID = [decoder decodeObjectOfClass:[FBSDKUserIdentifier class] forKey:FBSDKProfileCodingKeyUserID];
FBSDKUserIdentifier userID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDKProfileCodingKeyUserID];
NSString *firstName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyFirstName];
NSString *middleName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyMiddleName];
NSString *lastName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyLastName];
Expand All @@ -458,7 +458,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
NSDate *refreshDate = [decoder decodeObjectOfClass:NSDate.class forKey:FBSDKProfileCodingKeyRefreshDate];
NSURL *imageURL = [decoder decodeObjectOfClass:NSURL.class forKey:FBSDKProfileCodingKeyImageURL];
NSString *email = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyEmail];
NSArray<FBSDKUserIdentifier *> *friendIDs = [decoder decodeObjectOfClass:NSArray.class forKey:FBSDKProfileCodingKeyFriendIDs];
NSArray<FBSDKUserIdentifier> *friendIDs = [decoder decodeObjectOfClass:NSArray.class forKey:FBSDKProfileCodingKeyFriendIDs];
BOOL isLimited = [decoder decodeBoolForKey:FBSDKProfileCodingKeyIsLimited];
NSDate *birthday = [decoder decodeObjectOfClass:NSDate.class forKey:FBSDKProfileCodingKeyBirthday];
FBSDKUserAgeRange *ageRange = [decoder decodeObjectOfClass:FBSDKUserAgeRange.class forKey:FBSDKProfileCodingKeyAgeRange];
Expand Down Expand Up @@ -545,7 +545,7 @@ + (nullable FBSDKProfile *)fetchCachedProfile
return nil;
}

+ (NSURL *)imageURLForProfileID:(FBSDKUserIdentifier *)profileId
+ (NSURL *)imageURLForProfileID:(FBSDKUserIdentifier)profileId
pictureMode:(FBSDKProfilePictureMode)mode
size:(CGSize)size
{
Expand Down Expand Up @@ -655,7 +655,7 @@ + (void)loadProfileWithToken:(FBSDKAccessToken *)token
if (urlString) {
linkUrl = [FBSDKTypeUtility coercedToURLValue:[NSURL URLWithString:urlString]];
}
NSArray<FBSDKUserIdentifier *> *friendIDs = [self friendIDsFromGraphResult:[FBSDKTypeUtility dictionaryValue:result[@"friends"]]];
NSArray<FBSDKUserIdentifier> *friendIDs = [self friendIDsFromGraphResult:[FBSDKTypeUtility dictionaryValue:result[@"friends"]]];
FBSDKUserAgeRange *ageRange = [FBSDKUserAgeRange ageRangeFromDictionary:[FBSDKTypeUtility dictionaryValue:result[@"age_range"]]];

[FBSDKProfile.dateFormatter setDateFormat:@"MM/dd/yyyy"];
Expand Down Expand Up @@ -728,14 +728,14 @@ + (void)observeChangeAccessTokenChange:(NSNotification *)notification
[self loadProfileWithToken:token completion:NULL];
}

+ (nullable NSArray<FBSDKUserIdentifier *> *)friendIDsFromGraphResult:(NSDictionary<NSString *, id> *)result
+ (nullable NSArray<FBSDKUserIdentifier> *)friendIDsFromGraphResult:(NSDictionary<NSString *, id> *)result
{
NSArray<NSDictionary<NSString *, id> *> *rawFriends = [FBSDKTypeUtility arrayValue:result[@"data"]];
NSMutableArray<FBSDKUserIdentifier *> *friendIDs = [NSMutableArray new];
NSMutableArray<FBSDKUserIdentifier> *friendIDs = [NSMutableArray new];

for (NSDictionary<NSString *, id> *rawFriend in rawFriends) {
if ([FBSDKTypeUtility dictionaryValue:rawFriend]) {
FBSDKUserIdentifier *friendID = [FBSDKTypeUtility coercedToStringValue:rawFriend[@"id"]];
FBSDKUserIdentifier friendID = [FBSDKTypeUtility coercedToStringValue:rawFriend[@"id"]];
[FBSDKTypeUtility array:friendIDs addObject:friendID];
}
}
Expand Down
17 changes: 8 additions & 9 deletions FBSDKCoreKit/FBSDKCoreKit/include/FBSDKProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ typedef void (^ FBSDKProfileBlock)(FBSDKProfile *_Nullable profile, NSError *_Nu
NS_SWIFT_NAME(ProfileBlock);

/// Represents the unique identifier for an end user
typedef NSString FBSDKUserIdentifier
NS_SWIFT_NAME(UserIdentifier);
typedef NSString *FBSDKUserIdentifier NS_SWIFT_NAME(UserIdentifier) NS_SWIFT_BRIDGED_TYPEDEF;

/**
Represents an immutable Facebook profile
Expand Down Expand Up @@ -81,7 +80,7 @@ NS_SWIFT_NAME(Profile)
@param linkURL the link for this profile
@param refreshDate the optional date this profile was fetched. Defaults to [NSDate date].
*/
- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand Down Expand Up @@ -109,7 +108,7 @@ NS_SWIFT_NAME(Profile)
When true, `loadCurrentProfileWithCompletion:` will assume the profile is
incomplete and disregard any cached profile. Defaults to false.
*/
- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -118,7 +117,7 @@ NS_SWIFT_NAME(Profile)
refreshDate:(nullable NSDate *)refreshDate
imageURL:(nullable NSURL *)imageURL
email:(nullable NSString *)email
friendIDs:(nullable NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(nullable NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(nullable NSDate *)birthday
ageRange:(nullable FBSDKUserAgeRange *)ageRange
hometown:(nullable FBSDKLocation *)hometown
Expand All @@ -144,7 +143,7 @@ NS_SWIFT_NAME(Profile)
@param location the user's location
@param gender the user's gender
*/
- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID
- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -153,7 +152,7 @@ NS_SWIFT_NAME(Profile)
refreshDate:(nullable NSDate *)refreshDate
imageURL:(nullable NSURL *)imageURL
email:(nullable NSString *)email
friendIDs:(nullable NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(nullable NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(nullable NSDate *)birthday
ageRange:(nullable FBSDKUserAgeRange *)ageRange
hometown:(nullable FBSDKLocation *)hometown
Expand All @@ -173,7 +172,7 @@ NS_SWIFT_NAME(Profile)
NS_SWIFT_NAME(current);

/// The user id
@property (nonatomic, readonly, copy) FBSDKUserIdentifier *userID;
@property (nonatomic, readonly, copy) FBSDKUserIdentifier userID;
/// The user's first name
@property (nullable, nonatomic, readonly, copy) NSString *firstName;
/// The user's middle name
Expand Down Expand Up @@ -207,7 +206,7 @@ NS_SWIFT_NAME(current);
IMPORTANT: This field will only be populated if your user has granted your application the 'user_friends' permission.
*/
@property (nullable, nonatomic, readonly, copy) NSArray<FBSDKUserIdentifier *> *friendIDs;
@property (nullable, nonatomic, readonly, copy) NSArray<FBSDKUserIdentifier> *friendIDs;

/**
The user's birthday.
Expand Down
7 changes: 4 additions & 3 deletions FBSDKLoginKit/FBSDKLoginKit/FBSDKProfileCreating.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

#if !TARGET_OS_TV

#import <FBSDKCoreKit/FBSDKCoreKit.h>

@class FBSDKLocation;
@class FBSDKProfile;
@class FBSDKUserAgeRange;
typedef NSString FBSDKUserIdentifier;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -25,7 +26,7 @@ NS_SWIFT_NAME(_ProfileCreating)
@protocol FBSDKProfileCreating

// UNCRUSTIFY_FORMAT_OFF
- (FBSDKProfile *)createProfileWithUserID:(FBSDKUserIdentifier *)userID
- (FBSDKProfile *)createProfileWithUserID:(FBSDKUserIdentifier)userID
firstName:(nullable NSString *)firstName
middleName:(nullable NSString *)middleName
lastName:(nullable NSString *)lastName
Expand All @@ -34,7 +35,7 @@ NS_SWIFT_NAME(_ProfileCreating)
refreshDate:(nullable NSDate *)refreshDate
imageURL:(nullable NSURL *)imageURL
email:(nullable NSString *)email
friendIDs:(nullable NSArray<FBSDKUserIdentifier *> *)friendIDs
friendIDs:(nullable NSArray<FBSDKUserIdentifier> *)friendIDs
birthday:(nullable NSDate *)birthday
ageRange:(nullable FBSDKUserAgeRange *)ageRange
hometown:(nullable FBSDKLocation *)hometown
Expand Down
4 changes: 3 additions & 1 deletion FBSDKLoginKit/FBSDKLoginKit/Internal/_ProfileFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#if !os(tvOS)

import FBSDKCoreKit

/**
Internal Type exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
Expand All @@ -20,7 +22,7 @@ public final class _ProfileFactory: NSObject, _ProfileCreating {

// swiftlint:disable:next function_parameter_count
public func createProfile(
userID: String,
userID: UserIdentifier,
firstName: String?,
middleName: String?,
lastName: String?,
Expand Down

0 comments on commit 189920c

Please sign in to comment.