omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Way for the widget to tell if the phone is locked?

    Pythonista
    2
    3
    1467
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SaltlessLemons
      SaltlessLemons last edited by

      Okay, I've built a TOTP key widget and it works perfectly. There's one glaring problem, and that is that it works while the phone is locked, so anyone can just swipe and see all the keys. Is there any way for the widget to know if the phone is locked or not?

      I'd like for it to work if the phone is unlocked, but not necessarily off the lock screen. Similar to how the widget for the Files app works.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        StackOverflow says to check for

        UIApplication.sharedApplication().isProtectedDataAvailable()
        

        Though I have not tested in the widget.

        1 Reply Last reply Reply Quote 2
        • SaltlessLemons
          SaltlessLemons last edited by SaltlessLemons

          UIApplication.sharedApplication().isProtectedDataAvailable()

          Works perfectly. Only thing to note is that it doesn't return False unless the phone has been locked for ~10 seconds or more. That's perfect, thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors