I am trying add Facebook login feature to my swiftUi app. But getting the following error when I download it from testFlight and installed it on a real device.
When I am trying to check it on simulator I get the following error:
Here is the login function:
func loginWithFacebook() {
let loginManager = LoginManager()
loginManager.logOut()
loginManager.logIn(permissions: ["public_profile"], from: nil) { result, error in
if let error = error {
// showAlert(msg: "Facebook login failed with error: \(error.localizedDescription)")
print("Facebook login failed with error: \(error.localizedDescription)")
// Handle login failure
} else if result?.isCancelled == true {
// showAlert(msg: "Facebook login was cancelled")
print("Facebook login was cancelled")
// Handle login cancellation
} else {
print("Facebook login successful")
guard let token = AccessToken.current else { return }
if token.hasGranted(permission: "public_profile") {
// Perform a Graph API request to get user's profile data
let graphRequest = GraphRequest(graphPath: "me", parameters: ["fields": "id,name"], tokenString: token.tokenString, version: nil, httpMethod: .get)
graphRequest.start { _, result, error in
if let error = error {
showAlert(msg: "Failed to fetch Facebook user data: \(error.localizedDescription)")
print("Failed to fetch Facebook user data: \(error.localizedDescription)")
// Handle the error
} else if let userData = result as? [String: Any] {
// Extract user information
if let userID = userData["id"] as? String,
let userName = userData["name"] as? String {
print("User ID: \(userID)")
print("User Name: \(userName)")
// Perform additional actions with the user data
otherLogingType = "facebook"
submitOtherLogin(username: userName, userEmail: "", userId: userID)
// showAlert(msg: "No issue with Facebook, check other login API")
}
}
}
}
}
}
}
I have checked all the documents and nothing really helped.