-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Login fails on iOS PlatformException(FAILED, The operation couldn’t be completed. (com.facebook.sdk.core error 8.), null, null) #417
Comments
@darwin-morocho A same issue facing. Error
|
@DavidHajum try this version 6.0.0 for temporary solution. working for me. |
The solution of @furkan-wve seems to work for now, thanks :) |
I'm experiencing a similar issue. Seems that the sign in options are what fails, ex. |
Same problem still continue.There is no issue in version 6.2.0, but there is an issue in version 7.0.2. Dart Code: import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final _auth = FacebookAuth.instance;
late LoginPageState _state;
@override
void initState() {
super.initState();
_init();
}
Future<void> _init() async {
setState(() {
_state = LoginLoading();
});
final accessToken = await _auth.accessToken;
if (accessToken != null) {
await _getUserProfile(accessToken.tokenString);
} else {
setState(() {
_state = LoginNotAuthenticated();
});
}
}
Future<void> _getUserProfile(String accessToken) async {
final data = await _auth.getUserData();
if (data.isEmpty) {
await _logout();
return;
}
setState(() {
_state = LoginSuccessful(
User(
userId: data['id'] as String,
accessToken: accessToken,
name: data['name'] as String,
pictureProfile: data['picture']?['data']?['url'] as String,
email: data['email'] as String,
),
);
});
}
Future<void> _logout() async {
await _auth.logOut();
setState(() {
_state = LoginNotAuthenticated();
});
}
Future<void> _login() async {
setState(() {
_state = LoginLoading();
});
final result = await _auth.login(
loginTracking: LoginTracking.limited,
);
switch (result.status) {
case LoginStatus.success:
await _getUserProfile(result.accessToken!.tokenString);
case LoginStatus.cancelled:
case _:
setState(() {
_state = LoginNotAuthenticated();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizedBox(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
ElevatedButton(
onPressed: () {
_logout();
},
child: Text("logout")),
Center(
child: switch (_state) {
LoginLoading() => const CircularProgressIndicator(),
LoginNotAuthenticated() => ElevatedButton(
onPressed: _login,
child: const Text('Login'),
),
LoginSuccessful(user: final User user) => Text(
prettyPrint(
user.toJson(),
),
),
},
),
],
),
),
);
}
}
// Abstract base class representing login page states
sealed class LoginPageState {}
// State representing the login page is loading
class LoginLoading extends LoginPageState {}
// State representing the user is not logged in
class LoginNotAuthenticated extends LoginPageState {}
// State representing the user is successfully logged in
class LoginSuccessful extends LoginPageState {
final User user;
LoginSuccessful(this.user);
}
class User {
final String userId;
final String accessToken;
final String name;
final String? pictureProfile;
final String? email;
User({
required this.userId,
required this.accessToken,
required this.name,
required this.pictureProfile,
required this.email,
});
Map<String, dynamic> toJson() => {
'userId': userId,
'name': name,
'accessToken': accessToken,
'pictureProfile': pictureProfile,
'email': email,
};
}
String prettyPrint(Map json) {
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
String pretty = encoder.convert(json);
return pretty;
}
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(FAILED, The operation couldn’t be completed. (com.facebook.sdk.core error 8.), null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
message_codecs.dart:648
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
platform_channel.dart:334
<asynchronous suspension>
#2 FacebookAuthPlatformImplementation.getUserData (package:flutter_facebook_auth_platform_interface/src/facebook_auth_implementation.dart:84:20)
facebook_auth_implementation.dart:84
<asynchronous suspension>
#3 FacebookAuth.getUserData (package:flutter_facebook_auth/flutter_facebook_auth.dart:70:20)
flutter_facebook_auth.dart:70
<asynchronous suspension>
#4 _LoginPageState._getUserProfile (package:flutter_riverpod_template/new_page.dart:41:18)
new_page.dart:41
<asynchronous suspension>
#5 _LoginPageState._login (package:flutter_riverpod_template/new_page.dart:78:9)
new_page.dart:78
<asynchronous suspension> |
I had the same problem. I solved it using the following code.
|
I stumbled on this issue today as well as a result of upgrading the package. As far as I understand, getUserData cannot be used with Limited login as it goes over Graph API and the token received from Limited Login just does not work with Graph API. Tracking status can be indeed used to toggle between Limited and normal login, however that is not acceptable solution as in case Limited Login various profile information seems to be missing (name, email, profile picture, etc). Or at least I do not find currently any place to where it is populated. As per Facebook documentation (https://developers.facebook.com/docs/facebook-login/limited-login/ios/) in case of Limited Login it is possible specify permissions and as a result some profile information is populated for a successful login (https://developers.facebook.com/docs/facebook-login/limited-login/ios/#implement-limited-login). Currently I do not understand where in flutter_facebook_auth this populated profile information is available. Is it populated at all @darwin-morocho ? |
the solution of @furkan-wve works me too |
version: 7.1.1
|
What version are you using?
7.0.1
What OS and version are you using to local deploy your application?
macOS 14.5
What platforms are you seeing the problem on?
iOS
pubspec.yaml
Describe the Bug
I get this error, when I try to log in on iOS:
PlatformException(FAILED, The operation couldn’t be completed. (com.facebook.sdk.core error 8.), null, null)
I followed this instruction for the setup and tried this suggestion on StackOverflow, but no luck so far.
My code currently looks like this:
The login functionality works without problems on Android.
I'm using a test account to log in.
Expected Behavior
The login function returns normally
To Reproduce
Make a login call
Relevant log output
No response
flutter doctor -v
Info.plist (iOS)
No response
Podfile (iOS)
No response
AndroidManifest.xml
No response
MainActivity.java
No response
MainActivity.kt
No response
index.html
No response
Info.plist (macOS)
No response
The text was updated successfully, but these errors were encountered: