Skip to content

local_auth gives incorrect results in iOS 9.x and iOS 10.x #27366

@danwulff

Description

@danwulff

Issue

LocalAuthentication().canCheckBiometrics returns false in iOS 9.x and iOS 10.x, with Touch ID enabled. (Strangely it returns true with Touch ID disabled)

Additionally LocalAuthentication().getAvailableBiometrics() returns an empty array whether or not Touch ID is enabled.

This is reproducible on both a simulator and physical device.

Note: this may be present on other device models, our team originally found this issue on a iPhone 6 which is why it has been used for testing.

Expected Functionality

canCheckBiometrics and getAvailableBiometrics should work in iOS 9.x and 10.x.

Steps to Reproduce

  • git clone https://github.com/danwulff/flutter_local_auth_bug.git
  • cd flutter_local_auth_bug/
  • Open an iOS simulator with iPhone 6 and iOS 10.x or 9.x
  • Ensure Touch ID is enabled in the Simulator (in the menus, Hardware -> Touch ID -> Enrolled ✔️)

For reference: the main.dart file from the above repo is copied here:

import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final localAuth = LocalAuthentication();

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _canCheckBiometricsResult;
  List<BiometricType> _getAvailableBiometricsResult;

  void _checkBiometrics() async {
    final checkResult = await widget.localAuth.canCheckBiometrics;
    final getResult = await widget.localAuth.getAvailableBiometrics();
    setState(() {
      _canCheckBiometricsResult = checkResult;
      _getAvailableBiometricsResult = getResult;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('local_auth bug'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'The result of canCheckBiometrics:',
            ),
            Text(
              '${_canCheckBiometricsResult ?? ''}',
              style: Theme.of(context).textTheme.display1,
            ),
            Text(
              'The result of getAvailableBiometrics (length):',
            ),
            Text(
              '${_getAvailableBiometricsResult?.length ?? ''}',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _checkBiometrics,
        tooltip: 'Increment',
        child: Icon(Icons.update),
      ),
    );
  }
}

Logs

flutter doctor -v

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-US)
    • Flutter version 1.0.0 at /Users/dwulff/development/flutter
    • Framework revision 5391447fae (9 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/dwulff/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/dwulff/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.3
    • Dart plugin version 182.5124
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] VS Code (version 1.30.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.22.3

[✓] Connected device (1 available)
    • iPhone 6 • B5FE1F3A-110A-40F1-88EF-5227C6947393 • ios • iOS 9.3 (simulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: local_authPlugin for local authentificationpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions