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

Issue with the dependency setting #6

Closed
BSTomack opened this issue Aug 22, 2020 · 4 comments
Closed

Issue with the dependency setting #6

BSTomack opened this issue Aug 22, 2020 · 4 comments

Comments

@BSTomack
Copy link

BSTomack commented Aug 22, 2020

I've tried playing around with this package and ran into a problem getting it to work. I reduced your example to the most basic structure:
main.dart:

return MaterialApp(
  home: SecureApplication(
    nativeRemoveDelay: 1000,
    child: MainBody(),
  ),
);

}
main_body.dart:

var width = MediaQuery.of(context).size.width * 0.8;
return Scaffold(
  appBar: AppBar(
    title: const Text('Secure Window Example'),
  ),
  body: Center(
    child: FlutterLogo(
      size: width,
    ),
  ),
);

}
When I changed the dependency from:

dev_dependencies:
  secure_application:
    path: ../

Screen Shot 2020-08-22 at 10 21 18 AM

to the prescibed:

dependencies:
  secure_application: ^3.5.3

Screen Shot 2020-08-22 at 10 24 14 AM

The blur no longer worked when the app was minimized. I've tried this with a few different configuration and always get the same result. Can you provide any insight into what's going on?

@BSTomack
Copy link
Author

BSTomack commented Aug 22, 2020

I see now that my "../" version writes the SwiftSecureApplicationPlugin.swift like this:

public func applicationWillResignActive(_ application: UIApplication) {
        self.registerBackgroundTask()
        UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch()
        if let window = UIApplication.shared.windows.filter({ (w) -> Bool in
                   return w.isHidden == false
        }).first {
            if let existingView = window.viewWithTag(99699), let existingBlurrView = window.viewWithTag(99698) {
                window.bringSubviewToFront(existingView)
                window.bringSubviewToFront(existingBlurrView)
                return
            } else {
                ...

where as my "secure_application: ^3.5.3" version writes it like this:

public func applicationWillResignActive(_ application: UIApplication) {
    if ( secured ) {
        self.registerBackgroundTask()
        UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch()
        if let window = UIApplication.shared.windows.filter({ (w) -> Bool in
                   return w.isHidden == false
        }).first {
            if let existingView = window.viewWithTag(99699), let existingBlurrView = window.viewWithTag(99698) {
                window.bringSubviewToFront(existingView)
                window.bringSubviewToFront(existingBlurrView)
                return
            } else {
                ...

I tried this:

return MaterialApp(
      home: SecureApplication(
        nativeRemoveDelay: 1000,
        secureApplicationController: SecureApplicationController(
          SecureApplicationState(
            locked: false,
            secured: true,
            paused: false,
            authenticated: false,
          ),
        ),
        child: MainBody(),
      ),
    );

but had no luck. What do you do to set secured to default to true?

@BSTomack
Copy link
Author

Nevermind...

Widget build(BuildContext context) {
    
    return MaterialApp(
      home: SecureApplication(
        nativeRemoveDelay: 1000,
        child: Builder(builder: (context) {
          SecureApplicationProvider.of(context).secure();
          return MainBody();
        }),
      ),
    );
  }

@neckaros
Copy link
Owner

You were too fast for me to even see the initial question!
Glad you sorted it out!

@BSTomack
Copy link
Author

Your code is great! Thank you!

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