Closed saulharov closed 1 year ago
@saulharov according to your logs you are calling to getUserData. Please add the full dart code to check what is the problem
@saulharov according to your logs you are calling to getUserData. Please add the full dart code to check what is the problem
@darwin-morocho
Note that this code works fine with Android, the problem is just in iOS.
Widget _facebookLoginButton(BuildContext context) {
return TextButton(
onPressed: () async {
FacebookAuth.instance.login(
permissions: ['public_profile', 'email']).then((value) {
FacebookAuth.instance.getUserData().then((userData) async {
Session.save(userData['name'], userData['email']);
Navigator.pushNamedAndRemoveUntil(context, '/welcome', (Route<dynamic> route) => false);
}
}
);
},
child: Text('login facebook'),
);
}
@saulharov before get the user data you must check if the login was successful
final result = await FacebookAuth.i.login();
if (result.status == LoginStatus.success) {
final userData = await FacebookAuth.i.getUserData();
Session.save(userData['name'], userData['email']);
Navigator.pushNamedAndRemoveUntil(context, '/welcome', (Route<dynamic> route) => false);
} else {
print(result.status);
print(result.message);
}
@saulharov before get the user data you must check if the login was successful
@darwin-morocho You are right, i changed the code and now I get:
flutter: LoginStatus.failed
flutter: The operation couldn’t be completed. (com.facebook.sdk.core error 309.)
I checked some answers, like https://github.com/facebook/facebook-ios-sdk/issues/1879, at it says that the clock/time was adjusted manually but I guarantee that I didn't change any clock in the system or emulator. It say that the problem might be with Facebook SDK 11 and later. What should I do about that?
Its done. I don't know what happened or why it happened but I had to create a new project, add the library again, and it worked. I don't know how, I have no idea. Maybe some file that worked on and I edited trying to find an answer and I didn't remember... but whatever, it finally worked. I wish I could give a specific answer but I have none. Sorry. Thanks to @darwin-morocho the code correction.
What version are you using?
flutter_facebook_auth: ^5.0.7
What OS and version are you using to local deploy your application?
Ventura 13.0.1
What platforms are you seeing the problem on?
IOS 16.1 iPhone 14 Pro (emulator) using
pubspec.yaml
Describe the Bug
The library and code WORKS without issues in Android emulator but, when I try to run in the iOS emulator it doesn't work. I press the button, sends me to Facebook, login and return me to the app but the error is displayed.
I tried to change LSApplicationQueriesSchemes using fbapi, fbauth2, fb-messenger-share-api and nothing.
I tried to change AppDelegate.swift according to this page https://developers.facebook.com/docs/ios/getting-started?locale=es_LA but i undo that because I didn't know what i was doing. And this too https://developers.facebook.com/docs/facebook-login/ios/
Tried tis https://facebook.meedu.app/docs/5.x.x/ios/ and, obviously, this https://github.com/darwin-morocho/flutter-facebook-auth/issues/261. This too https://www.reddit.com/r/iOSProgramming/comments/4vvaxa/the_operation_couldnt_be_completed/
I have no idea of swift, I'm just using dart.
I'm just tired to try so many things.
If you need more info don't hesitate to request it.
Expected Behavior
The user press the button, is sent to Facebook page for login, logins, the app receives the user info (email, name, id), and sends the user to another screen.
To Reproduce
The widget used inside screen:
AppDelegate.swift Didn't change it but for reference
Relevant log output
flutter doctor -v
Info.plist (iOS)
Podfile (iOS)
AndroidManifest.xml
No response
MainActivity.java
No response
MainActivity.kt
No response
index.html
No response
Info.plist (macOS)
No response