I'm trying to get biometrics authentication to work again after updating the app I'm developing.
But I'm constantly getting the same error when activating it:
PlatformException(NotAvailable, Required security features not enabled, null, null)
The current one in the store has no problems at all.
I'm using local_auth: 1.1.4
MainActivity.java has been converted to a FragmentedActivity
I'm doing a simple check to see if the biometrics are available. Which they are
bool canCheckBiometrics = await auth.canCheckBiometrics;
List<BiometricType> availableBiometrics =
await auth.getAvailableBiometrics();
print(canCheckBiometrics); //Returns true
print(availableBiometrics.toString()); //Returns [BiometricType.fingerprint]
After that I try to do the authentication
try {
authenticated = await auth.authenticate(
biometricOnly: true,
localizedReason: 'Login with biometrics',
useErrorDialogs: true,
stickyAuth: false);
} on PlatformException catch (e) {
print(e);
}
This returns:
PlatformException(NotAvailable, Required security features not enabled, null, null)
And this is what the plugin comments in the code say.
// Indicates the device does not have a Touch ID/fingerprint scanner.
const String notAvailable = 'NotAvailable';
I'm not really sure what to check anymore. Is this something new I need to be aware of?
Really hope someone can help me with this issue!
Hope to hear!
I recommend that you verify all capabilities before of try authenticate the user.
Future<bool> authenticateIsAvailable() async {
final isAvailable = await localAuth.canCheckBiometrics;
final isDeviceSupported = await localAuth.isDeviceSupported();
return isAvailable && isDeviceSupported;
}
This way, you can call localAuth.authenticate only for phones that have credentials enrolled and probably don't have exceptions. Even though, catch the error if possible.
First of all, you need to add a biometric authentication method to your device from settings.
For example if you are using Pixel 2 API 32 as Android Emulator,
Go to Settings inside android emulator.
Go into Security
Under the Device Security section, select Pixel Imprint
Android will ask you to put your finger on the sensor, in this part you should click the Touch Sensor button from the Extended Emulator Settings of Android Studio.
After turning on fingerprint verification in this way, when you return to the application and try again, you will see that the error is gone.
Similarly, if you are trying with a real device or another emulator, you need to enable fingerprint authentication and try again.
I think you don't have a fingerprint activated yet, or you don't have permissions to use it, check the permissions and try again.
Check this out:
https://support.dashlane.com/hc/en-us/articles/203682911-How-to-set-biometric-authentication-or-a-PIN-code-to-unlock-Dashlane-on-Android
Go to settings -> security -> fingerprint and add fingerprint lock.
If you are using Android studio emulator then keep in mind that Android Studio emulator provides fake fingerprint scanning.
I had the same issue and after debugging I discovered that keyguardManager was always null and causing the plugin to throw not enable exception. I had to change the below method in LocalAuthPlugin as follows:
private boolean isDeviceSupported()
{
if (keyguardManager == null) return false;
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
keyguardManager.isDeviceSecure());
}
to
private boolean isDeviceSupported()
{
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
}
It worked for me, hopefully will work for you and others.
Related
I just released my first app and It has a button in it that takes you to a website.
A user just sent me this:.
I tried googling Google's secure browsers policy but not much info is coming up.
how can I make my app comply with this policy? I think the button opens a browser in app (I use duckduckgo as my default browser and haven't had an issue)
is it just a case of opening a browser and then heading to the website when the button is pressed?
my code to open the website is:
_launchURL() async {
const url = 'https://www.thiswebsite.com';
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
}
thanks so much and any help would be greatly appreciated
Google is trying to make sure, you open this window in an actual new browser window, not in a webview still under the control of your application.
Your code should open an external browser.
Maybe the user has no browser installed on their device? Maybe their default browser is some exotic thing not recognized by Google?
If you are using the latest version of url_launcher (currently 6.1.8) there is not a lot more you can do.
You could force the app to take the external browser, not the in-app webview:
await launchUrl(_url,mode: LaunchMode.externalApplication);
But that should be what happens anyway. If your version is up to date, ask your user, what browser they use. Be prepared to tell them that they need to use another one.
After spending hours for getting App Check working on the physical devices (iOS and Android) of my Flutter app i also tried the provided documentation steps in order to get it working for Android emulator as well.
Whatever i try i always get the following error for all my listening streams that are invoked against the Firestore database when App Check is enforced:
W/Firestore( 5612): (24.1.2) [Firestore]: Listen for Query(target=Query(Contract where isArchive==false and contractorId==myContractorId order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
I've added the depencency in app/build.gradle:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-appcheck-debug:16.0.0'
}
and have overridden onCreate in MainActivity.kt:
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
if (BuildConfig.DEBUG) {
//Log.d("MainActivity", "debug mode entered")
FirebaseApp.initializeApp( /*context=*/this)
val firebaseAppCheck: FirebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(DebugAppCheckProviderFactory.getInstance())
} else {
//Log.d("MainActivity", "else mode entered")
}
super.onCreate(savedInstanceState)
}
}
The resulting debug token was added successfully to the list of debug tokens in Firebase console.
All Firestore collection rules look like the following example rule:
match /Contractor/{contractor} {
allow read, write: if request.auth.uid != null;
}
Activating App Check in the Flutter main function looks like this:
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await FirebaseAppCheck.instance.activate();
Without enforced App Check i don't have any problems running the Flutter app on my Android emulator.
All Firebase plugins are the most recent ones.
What else can i try or change in order to get this working?
If it doesn't work also on Android emulators we will give up using App Check.
Have you added this in cloud function:
if (context.app == undefined && !process.env.FUNCTIONS_EMULATOR) {
throw new functions.https.HttpsError(
"failed-precondition",
"The function must be called from an App-Check verified app.");
}
You need to add this code:
!process.env.FUNCTIONS_EMULATOR
I created a flutter web app that creates an image and generates the base64 data. so I used AnchorElement in the HTML package to download the image to the client, it works on mac and windows but when I want to be downloaded on mobile nothing happen at all.
any clue?
code:
Future<void> downloadImage(Uint8List data8) async {
try {
final base64data = base64Encode(data8);
final a = html.AnchorElement(href: 'data:image/jpeg;base64,$base64data');
a.download = 'image.jpg';
a.click();
a.remove();
} catch (e) {
print(e);
}
}
In general mobile apps need rights to access certain resource, e.g. access the network.
Search for entitlement on iOS like this and manifest on Android.
You need to set these rights in the iOS or Android project. Without this rights, access gets simply denied.
Sorry to ask this here but couldnt find any information related to this online. In native java I have used intent to select com.whatsapp.w4b and com.whatsapp.
I cant figure out how to do it with dart. So far I know:
String androidUrl = 'https://wa.me/$recipientMobile/?text=${Uri.parse(message)}';
String iosUrl = 'https://api.whatsapp.com/send?phone=$recipientMobile=${Uri.parse(message)}';
if (Platform.isAndroid) {
await launch(androidUrl);
} else if (Platform.isIOS) {
if(await canLaunch(iosUrl)){
await launch(iosUrl);
} else {
showToast('Error! Try again.', 'Short');
}
}
This code works but only launches default WhatsApp. How to launch bussiness / personal whatsapp?
Thanks in advance.
EITHER you'll have to ask the users to change the defaults in the link settings of the phone as suggested here.
OR you'll have to share a link that they paste in the browser which will open the app selection section of the phone with both the options, as shown here.
It is strange that Firebase can't create user in Unity SDK out of the box.
Firebase Console was tuned (anonymous access and email/password access are enabled) and google-service.json was placed in Assets folder of Unity.
However, Firebase still won't create a user. This is the code where it always fails:
auth.SignInAnonymouslyAsync().ContinueWith(task => {
if (task.IsCompleted && !task.IsCanceled && !task.IsFaulted) {
Debug.Log("User is now signed in.");
FirebaseUser newUser = task.Result;
}
else if (task.IsFaulted || task.IsCanceled)
{
Debug.Log("User signup failed");
}
});
Why?
There are possible several reasons:
The app was run in the Editor, rather than on the device
The configuration file is not updated after you add Firebase Auth feature
The password is shorter than 6 chacters
The email address is in invalid form, e.g. abcdef#aaa
The first one is highly likely the reason why.
I have created a tutorial here, which covers the steps to create/login using firebase in Unity, hope this is helpful.