Login with facebook works on real phones but not emulators, it started happening with the new emulator update - flutter

This code works on real phones but not on emulators
I use flutter_facebook_auth. This exact code worked fine before emulator update and it's still works on real devices, but on emulator it just do nothing after coming back from fb login page.
static Future<User?> signInWithFacebook() async {
try {
//Trigger the sign-in flow
final LoginResult loginResult =
await FacebookAuth.instance.login(permissions: [
'public_profile',
'email',
'user_friends',
]);
if (loginResult.status == LoginStatus.success) {
print('success');
facebookAuthCredential =
FacebookAuthProvider.credential(loginResult.accessToken!.token);
print(loginResult.accessToken?.token);
Credential = await FirebaseAuth.instance
.signInWithCredential(facebookAuthCredential);
print('here 1');
UserData = await FacebookAuth.instance.getUserData(
fields:
"name,email,picture.width(400),birthday,friends,gender,link");
print(UserData);
} else {
print(loginResult.message);
error = loginResult.message!;
}
user = Credential.user;
await user
?.updatePhotoURL(UserData['picture']['data']['url'])
.then((value) {
print('success' + UserData['picture']['data']['url']);
});
return Credential.user;
} on FirebaseException catch (e) {
error = e.code;
print(e.code);
}
}
}
In the above code the app flow stops or freezes on
Credential = await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
What I have tried is:
Tried other emulators, different api's and models.
I tried adding new release and debug keyhashes to both facebook and firebase
I tried increasing emulator ram and cpu cores etc
I tried refreshing fb sdk and json and other dev dependencies
I tried flutter clean
I tried Invalidate Caches
I uninstalled android studio and all of it's components and install again
Is this happening with just me or it's a bug in the new emulator update?
It's been 12 hours, can somebody please help and check if their updated emulator is working with fb login

I solved it by downgrading emulator version to 31.2.9,
Here is emulator_archive how you can do it:

Related

Flutter lost focus on phone if Android Auto runs Waze

I launch Waze from App with this code with button click:`enter code here
void launchWaze(String lat, String lng) async {
Uri url = Uri.parse(
'https://waze.com/ul?ll=$lat,$lng&navigate=yes');
Uri fallbackUrl =
Uri.parse('https://waze.com/ul?ll=$lat,$lng&navigate=yes');
try {
bool launched = await launchUrl(
url,
mode: LaunchMode.externalApplication, // or externalNonBrowserApplication,
);
} catch (e) {
await launchUrl(fallbackUrl);
}
}
Waze launched from app, on Android Auto starts and route is fine, but the focus not in my app anymore so I can not use the app to start other location, only a text you use Waze on Android Auto. Back button not working...
Is there any solution to navigate on Android Auto and use the app on phone the same time?

Firebase remote config not updating and using older value+ Flutter

When we have a higher version available on the play store. This feature redirects users to the app store to install updates. But it is not working on a few devices. The user still using the older version. If the user clears the storage then an alert is displayed. We can not ask our users to clear storage. Any help would be greatly appreciated.
#override
void initState() {
super.initState();
try {
versionCheck(context);
} catch (e) {
print(e);
}
}
versionCheck(context) async {
//Get Current installed version of app
final PackageInfo info = await PackageInfo.fromPlatform();
double currentVersion =
double.parse(info.version.trim().replaceAll(".", ""));
//Get Latest version info from firebase config
final FirebaseRemoteConfig remoteConfig =
await FirebaseRemoteConfig.instance;
try {
// Using default duration to force fetching from remote server.
await remoteConfig.fetch();
await remoteConfig.fetchAndActivate();
remoteConfig.getString('force_update_current_version');
double newVersion = double.parse(remoteConfig
.getString('force_update_current_version')
.trim()
.replaceAll(".", ""));
if (newVersion > currentVersion) {
_showVersionDialog(context);
}
} on Exception catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print('Unable to fetch remote config. Cached or default values will be '
'used');
}
}
When I tried to print the values I am getting the same values new:160.0 current:160.0, clearing the storage of the app from the setting displays the alert.
I think your code in general looks right to me. Though there is a redundant line:
remoteConfig.getString('force_update_current_version');
But this should be fine.
What I am concerned about is that you replace all your . with empty and convert the version to a number. This can result in a bug if there are two versions like:
1.21.4 vs 1.2.15. The first one is supposed to be newer, but the code will get 1214 > 1215 is false

can't load iap products in local, it waits forever

I'm using the official in_app_purchase plugin, version ^1.0.4, and I'm following the official guide from Google insert my first iap (https://codelabs.developers.google.com/codelabs/flutter-in-app-purchases#0).
My consumable iap product is active on Play console with name "pacchetto_25", I've already submitted to the alpha channel my app and is accepted, the tester email is correctly configured in the Tester Group and in Licence Testing.
Now I'm trying to load the iap products in my app, the code is the same of the guide:
Future<void> loadPurchases() async {
final available = await _iap.isAvailable();
if (!available) {
print("STORE NOT AVAILABLE");
return;
} else {
print("STORE AVAILABLE");
const ids = <String>{
"pacchetto_25",
};
final response = await _iap.queryProductDetails(ids);
response.notFoundIDs.forEach((element) {
print('Purchase $element not found');
});
response.productDetails.forEach((element) {
print("Purchase $element found");
});
// products =
// response.productDetails.map((e) => PurchasableProduct(e)).toList();
}
}
In my console I have the "STORE AVAILABLE" message, but then nothing else. If I put same debug point it does not stops on them, this problem appear after this line:
final response = await _iap.queryProductDetails(ids);
Do someone know what's happening? I've no errors in my console and the code after loadPurchases() is not executed, it's like is waiting forever... Any ideas?
Solved! If you have the same issue DON'T put
implementation("com.android.billingclient:billing:4.0.0")
in your build.gradle

How to use Steam (OpenId) to login into my Firebase powered Flutter app?

I'm building a Flutter app and I want users to be able to login through Steam (OpenId).
The app is powered by Firebase.
I'm pretty new to the whole OpenId world and I've read into it but I'm still not getting it.
I found that Firebase Supports signinWithCustomToken so I think I should get the Steam OpenId to get me one of those.
I also found two packages which might help me but I couldn't get those to work either:
https://pub.dev/packages/openid_client
https://pub.dev/packages/steam_login
If tried the following sample from the openid_client package:
_authenticate(Uri uri, String clientId, List<String> scopes) async {
try {
var issuer = await Issuer.discover(uri);
var client = Client(issuer, clientId);
print('CLAIMS:');
print(issuer.claimsMap);
urlLauncher(String url) async {
if (await canLaunch(url)) {
await launch(url, forceWebView: true);
} else {
throw 'Could not launch $url';
}
}
var authenticator = Authenticator(client,
scopes: scopes, port: 4000, urlLancher: urlLauncher);
var c = await authenticator.authorize();
closeWebView();
print(await c.getUserInfo());
}catch (err) {
print(err);
}
}
But I have no idea what to give as the uri, clientId and scopes.
For the uri I've tried https://steamcommunity.com/openid but when I try this I'm getting an error that it tried to Json.parse a xml response.
I've also tried the example for the steam_login package here, but that does nothing and doesn't feel like it should work within a Flutter app (even though the package states it Flutter compatible).
So if anybody could explain to me how I could achieve this with a working sample that would be great.
If I get this to work I'm planning on creating a tutorial/guide for it for others.

Facebook login error using Flutter after install (Android)

I have a problem using the Facebook login in Flutter after installing into an Android device
My app was running fine with my Android device connected by USB (not using a virtual device), but when I build apk and install it using:
flutter build apk
flutter install
I cannot able to login using facebook, It always gives FacebookLoginStatus.error
I m using: flutter_facebook_login: ^1.2.0
I created 2 different facebook apps and the results were the same.
Whats missing? Thanks in advance!
Below is the source code what I have achieved so far:
void initiateFacebookLogin() async {
var facebookLoginResult =
await globals.facebookLogin.logInWithReadPermissions(['email','public_profile']);
print("face result ${facebookLoginResult.status}");
switch (facebookLoginResult.status) {
case FacebookLoginStatus.error:
showWarning('ERRO no login! Por favor, tente novamente!', context);
break;
case FacebookLoginStatus.cancelledByUser:
showWarning('Login cancelado pelo usuário!', context);
break;
case FacebookLoginStatus.loggedIn:
//print("LoggedIn");
var graphResponse = await http.get(
'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=${facebookLoginResult
.accessToken.token}');
profile = json.decode(graphResponse.body);
print(profile.toString());
Cadastro.name=profile['name'];
Cadastro.firstName=profile['firstname'];
Cadastro.lastName=profile['lastname'];
Cadastro.email=profile['email'];
Cadastro.id=profile['id'];
findUser(profile['email'],profile['email'],true).then((bool value){
//print("find user $value");
//if(value==false)
// Navigator.of(context).pushNamed(Cadastro.tag);
});
break;
}
}