Skip to content
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

Why application not locked after opening? #30

Closed
minhdanh opened this issue Feb 4, 2022 · 6 comments
Closed

Why application not locked after opening? #30

minhdanh opened this issue Feb 4, 2022 · 6 comments

Comments

@minhdanh
Copy link

minhdanh commented Feb 4, 2022

Hi, is there a reason this package doesn’t lock an app after launch? I’ve tried it and it just works when I switch to another app and come back. Can we make it work even when after we launch an app?

@minhdanh
Copy link
Author

I understand that the package uses the resume lifecycle event to execute the code. This event is fired when we switch to another app and switch back, or open the task switcher. But what is the point of locking an app, when you can bypass that by closing and opening the app again? 🤔

@neckaros
Copy link
Owner

neckaros commented Feb 11, 2022

I understand that the package uses the resume lifecycle event to execute the code. This event is fired when we switch to another app and switch back, or open the task switcher. But what is the point of locking an app, when you can bypass that by closing and opening the app again? 🤔

You are free to have a state locked by default on your app.
You can for example call lock on the SecureApplicationController

@minhdanh
Copy link
Author

Thank you for the hint. I can make app locked on first launch now:

        final secureApplicationController = SecureApplicationController(
          SecureApplicationState(
            locked: true,
            secured: true,
          ),
        );
        return MaterialApp(
          home: SecureApplication(
            secureApplicationController: secureApplicationController,
            nativeRemoveDelay: 500,
 ...

@minhdanh
Copy link
Author

One small question though, with the default state is locked, what else I should do for the callback onNeedUnlock to be called on app launch/opening (so that the app can ask for fingerprint automatically)?

@minhdanh
Copy link
Author

what else I should do for the callback onNeedUnlock to be called on app launch/opening (so that the app can ask for fingerprint automatically)?

I could do that by using WidgetsBinding.instance?.addPostFrameCallback:

class _UnlockScreenState extends State<UnlockScreen> {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance?.addPostFrameCallback((_) => localAuthenticate());
  }
...

@neckaros
Copy link
Owner

Nice find. I will see if I can not make a easier solution without adding too much complexity to the plug-in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants