Skip to content

Commit

Permalink
feat(ios): make all permitted user profile fields available when usin…
Browse files Browse the repository at this point in the history
…g limited login (#582)

* iOS limited login - map additional profile fields
* iOS limited login - fix age range mapping
* Run prettier
  • Loading branch information
ranjit-akalilabs authored Nov 26, 2024
1 parent 2aafb20 commit b297eb6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ios/RCTFBSDK/core/RCTFBSDKProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ - (dispatch_queue_t)methodQueue
@"linkURL": FBSDKProfile.currentProfile.linkURL ? FBSDKProfile.currentProfile.linkURL.relativeString : [NSNull null],
@"userID": FBSDKProfile.currentProfile.userID ? FBSDKProfile.currentProfile.userID : [NSNull null],
@"email": FBSDKProfile.currentProfile.email ? FBSDKProfile.currentProfile.email : [NSNull null],
@"refreshDate": FBSDKProfile.currentProfile.refreshDate ? @(FBSDKProfile.currentProfile.refreshDate.timeIntervalSince1970 * 1000) : [NSNull null],
@"friendIDs": FBSDKProfile.currentProfile.friendIDs ? FBSDKProfile.currentProfile.friendIDs : [NSNull null],
@"birthday": FBSDKProfile.currentProfile.birthday ? @(FBSDKProfile.currentProfile.birthday.timeIntervalSince1970 * 1000) : [NSNull null],
@"ageRange": FBSDKProfile.currentProfile.ageRange ? @{
@"min": FBSDKProfile.currentProfile.ageRange.min,
@"max": FBSDKProfile.currentProfile.ageRange.max
} : [NSNull null],
@"hometown": FBSDKProfile.currentProfile.hometown ? @{
@"id": FBSDKProfile.currentProfile.hometown.id,
@"name": FBSDKProfile.currentProfile.hometown.name
} : [NSNull null],
@"location": FBSDKProfile.currentProfile.location ? @{
@"id": FBSDKProfile.currentProfile.location.id,
@"name": FBSDKProfile.currentProfile.location.name
} : [NSNull null],
@"gender": FBSDKProfile.currentProfile.gender ? FBSDKProfile.currentProfile.gender : [NSNull null],
@"permissions": FBSDKProfile.currentProfile.permissions ? FBSDKProfile.currentProfile.permissions.allObjects : [NSNull null]
};
}

Expand Down
70 changes: 70 additions & 0 deletions src/FBProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export type ProfileMap = {
userID?: string | null;
email?: string | null;
name?: string | null;
refreshDate?: number | null;
friendIDs?: Array<string> | null;
birthday?: number | null;
ageRange?: {min: number; max: number} | null;
hometown?: {id: string; name: string} | null;
location?: {id: string; name: string} | null;
gender?: string | null;
permissions?: Array<string> | null;
};

/**
Expand Down Expand Up @@ -63,6 +71,58 @@ class FBProfile {
*/
imageURL?: string | null;

/**
* The last time the profile data was fetched.
*/
refreshDate?: Date | null;

/**
* A list of identifiers of the user’s friends.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_friends' permission and
* limited login flow is used on iOS
*/
friendIDs?: Array<string> | null;

/**
* The user’s birthday.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_birthday' permission and
* limited login flow is used on iOS
*/
birthday?: Date | null;

/**
* The user’s age range.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_age_range' permission and
* limited login flow is used on iOS
*/
ageRange?: {min: number; max: number} | null;

/**
* The user’s hometown.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_hometown' permission and
* limited login flow is used on iOS
*/
hometown?: {id: string; name: string} | null;

/**
* The user’s location.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_location' permission and
* limited login flow is used on iOS
*/
location?: {id: string; name: string} | null;

/**
* The user’s gender.
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_gender' permission and
* limited login flow is used on iOS
*/
gender?: string | null;

/**
* The user’s granted permissions.
*/
permissions?: Array<string> | null;

constructor(profileMap: ProfileMap) {
this.firstName = profileMap.firstName;
this.lastName = profileMap.lastName;
Expand All @@ -74,6 +134,16 @@ class FBProfile {
this.email = profileMap.email;
}
this.name = profileMap.name;
this.refreshDate = profileMap.refreshDate
? new Date(profileMap.refreshDate)
: null;
this.friendIDs = profileMap.friendIDs;
this.birthday = profileMap.birthday ? new Date(profileMap.birthday) : null;
this.ageRange = profileMap.ageRange;
this.hometown = profileMap.hometown;
this.location = profileMap.location;
this.gender = profileMap.gender;
this.permissions = profileMap.permissions;
Object.freeze(this);
}

Expand Down

0 comments on commit b297eb6

Please sign in to comment.