You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In iOS 17, the getProfile method is restricted when using Facebook's Limited Login. However, the Limited Login flow still provides access to a significant amount of user profile data through the supported permissions outlined in Facebook's Limited Login documentation.
Currently, developers need to implement custom logic to fetch this data.
Describe the solution you'd like
Enhance the getProfile method to include a fallback mechanism for retrieving user data when the Limited Login flow is detected. This can be achieved by directly using the getUserInfo method to fetch available data without requiring additional Graph API calls. Below is an example implementation of this solution:
@objc func getUserInfo(_ call: CAPPluginCall) {
guard let userProfile = Profile.current else {
call.reject("User profile not available. Ensure the user is logged in.")
return
}
// Map user profile fields to a dictionary
let userProfileData: [String: Any] = [
"id": userProfile.userID,
"name": userProfile.name ?? "",
"firstName": userProfile.firstName ?? "",
"middleName": userProfile.middleName ?? "",
"lastName": userProfile.lastName ?? "",
"email": userProfile.email ?? "",
"birthday": userProfile.birthday ?? "",
"gender": userProfile.gender ?? "",
]
// Resolve the call with user profile data
call.resolve(userProfileData)
}
@objc func getProfile(_ call: CAPPluginCall) {
// Get the tracking mode (default to "limited")
let tracking = call.getString("tracking") ?? "limited"
// Check if tracking is limited
if tracking == "limited" {
// Call getUserInfo directly for limited login
self.getUserInfo(call)
return
}
guard let accessToken = AccessToken.current else {
call.reject("You're not logged in. Call FacebookLogin.login() first to obtain an access token.")
return
}
if accessToken.isExpired {
call.reject("AccessToken is expired.")
return
}
guard let fields = call.getArray("fields", String.self) else {
call.reject("Missing fields argument")
return
}
let parameters = ["fields": fields.joined(separator: ",")]
let graphRequest = GraphRequest.init(graphPath: "me", parameters: parameters)
graphRequest.start { (_ connection, _ result, _ error) in
if error != nil {
call.reject("An error has occurred.")
return
}
call.resolve(result as! [String: Any])
}
}
Explanation
getUserInfo Method:
Retrieves the user profile data directly from the Profile.current object provided by Facebook's Limited Login.
Maps the user data (such as id, name, email, birthday, and gender) to a dictionary and resolves the plugin call with this data.
Fallback Logic in getProfile:
If the tracking parameter is set to "limited", the getProfile method invokes the getUserInfo method to fetch the available user data without relying on an active Graph API request or access token.
This ensures that developers can still access the user information available in the Limited Login context, even when getProfile cannot fetch additional data via the Graph API.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In iOS 17, the getProfile method is restricted when using Facebook's Limited Login. However, the Limited Login flow still provides access to a significant amount of user profile data through the supported permissions outlined in Facebook's Limited Login documentation.
Currently, developers need to implement custom logic to fetch this data.
Describe the solution you'd like
Enhance the getProfile method to include a fallback mechanism for retrieving user data when the Limited Login flow is detected. This can be achieved by directly using the getUserInfo method to fetch available data without requiring additional Graph API calls. Below is an example implementation of this solution:
Explanation
getUserInfo Method:
Fallback Logic in getProfile:
If the tracking parameter is set to "limited", the getProfile method invokes the getUserInfo method to fetch the available user data without relying on an active Graph API request or access token.
This ensures that developers can still access the user information available in the Limited Login context, even when getProfile cannot fetch additional data via the Graph API.
The text was updated successfully, but these errors were encountered: