Skip to content

Commit b297eb6

Browse files
feat(ios): make all permitted user profile fields available when using limited login (#582)
* iOS limited login - map additional profile fields * iOS limited login - fix age range mapping * Run prettier
1 parent 2aafb20 commit b297eb6

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

ios/RCTFBSDK/core/RCTFBSDKProfile.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ - (dispatch_queue_t)methodQueue
3535
@"linkURL": FBSDKProfile.currentProfile.linkURL ? FBSDKProfile.currentProfile.linkURL.relativeString : [NSNull null],
3636
@"userID": FBSDKProfile.currentProfile.userID ? FBSDKProfile.currentProfile.userID : [NSNull null],
3737
@"email": FBSDKProfile.currentProfile.email ? FBSDKProfile.currentProfile.email : [NSNull null],
38+
@"refreshDate": FBSDKProfile.currentProfile.refreshDate ? @(FBSDKProfile.currentProfile.refreshDate.timeIntervalSince1970 * 1000) : [NSNull null],
39+
@"friendIDs": FBSDKProfile.currentProfile.friendIDs ? FBSDKProfile.currentProfile.friendIDs : [NSNull null],
40+
@"birthday": FBSDKProfile.currentProfile.birthday ? @(FBSDKProfile.currentProfile.birthday.timeIntervalSince1970 * 1000) : [NSNull null],
41+
@"ageRange": FBSDKProfile.currentProfile.ageRange ? @{
42+
@"min": FBSDKProfile.currentProfile.ageRange.min,
43+
@"max": FBSDKProfile.currentProfile.ageRange.max
44+
} : [NSNull null],
45+
@"hometown": FBSDKProfile.currentProfile.hometown ? @{
46+
@"id": FBSDKProfile.currentProfile.hometown.id,
47+
@"name": FBSDKProfile.currentProfile.hometown.name
48+
} : [NSNull null],
49+
@"location": FBSDKProfile.currentProfile.location ? @{
50+
@"id": FBSDKProfile.currentProfile.location.id,
51+
@"name": FBSDKProfile.currentProfile.location.name
52+
} : [NSNull null],
53+
@"gender": FBSDKProfile.currentProfile.gender ? FBSDKProfile.currentProfile.gender : [NSNull null],
54+
@"permissions": FBSDKProfile.currentProfile.permissions ? FBSDKProfile.currentProfile.permissions.allObjects : [NSNull null]
3855
};
3956
}
4057

src/FBProfile.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ export type ProfileMap = {
1414
userID?: string | null;
1515
email?: string | null;
1616
name?: string | null;
17+
refreshDate?: number | null;
18+
friendIDs?: Array<string> | null;
19+
birthday?: number | null;
20+
ageRange?: {min: number; max: number} | null;
21+
hometown?: {id: string; name: string} | null;
22+
location?: {id: string; name: string} | null;
23+
gender?: string | null;
24+
permissions?: Array<string> | null;
1725
};
1826

1927
/**
@@ -63,6 +71,58 @@ class FBProfile {
6371
*/
6472
imageURL?: string | null;
6573

74+
/**
75+
* The last time the profile data was fetched.
76+
*/
77+
refreshDate?: Date | null;
78+
79+
/**
80+
* A list of identifiers of the user’s friends.
81+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_friends' permission and
82+
* limited login flow is used on iOS
83+
*/
84+
friendIDs?: Array<string> | null;
85+
86+
/**
87+
* The user’s birthday.
88+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_birthday' permission and
89+
* limited login flow is used on iOS
90+
*/
91+
birthday?: Date | null;
92+
93+
/**
94+
* The user’s age range.
95+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_age_range' permission and
96+
* limited login flow is used on iOS
97+
*/
98+
ageRange?: {min: number; max: number} | null;
99+
100+
/**
101+
* The user’s hometown.
102+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_hometown' permission and
103+
* limited login flow is used on iOS
104+
*/
105+
hometown?: {id: string; name: string} | null;
106+
107+
/**
108+
* The user’s location.
109+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_location' permission and
110+
* limited login flow is used on iOS
111+
*/
112+
location?: {id: string; name: string} | null;
113+
114+
/**
115+
* The user’s gender.
116+
* IMPORTANT: This field will only be populated if your user has granted your application the 'user_gender' permission and
117+
* limited login flow is used on iOS
118+
*/
119+
gender?: string | null;
120+
121+
/**
122+
* The user’s granted permissions.
123+
*/
124+
permissions?: Array<string> | null;
125+
66126
constructor(profileMap: ProfileMap) {
67127
this.firstName = profileMap.firstName;
68128
this.lastName = profileMap.lastName;
@@ -74,6 +134,16 @@ class FBProfile {
74134
this.email = profileMap.email;
75135
}
76136
this.name = profileMap.name;
137+
this.refreshDate = profileMap.refreshDate
138+
? new Date(profileMap.refreshDate)
139+
: null;
140+
this.friendIDs = profileMap.friendIDs;
141+
this.birthday = profileMap.birthday ? new Date(profileMap.birthday) : null;
142+
this.ageRange = profileMap.ageRange;
143+
this.hometown = profileMap.hometown;
144+
this.location = profileMap.location;
145+
this.gender = profileMap.gender;
146+
this.permissions = profileMap.permissions;
77147
Object.freeze(this);
78148
}
79149

0 commit comments

Comments
 (0)