neckaros / secure_application

Secure your application from prying eyes
MIT License
102 stars 57 forks source link

Issue with the dependency setting #6

Closed BSTomack closed 4 years ago

BSTomack commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Nevermind...

Widget build(BuildContext context) {

    return MaterialApp(
      home: SecureApplication(
        nativeRemoveDelay: 1000,
        child: Builder(builder: (context) {
          SecureApplicationProvider.of(context).secure();
          return MainBody();
        }),
      ),
    );
  }
neckaros commented 4 years ago

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

BSTomack commented 4 years ago

Your code is great! Thank you!