iOS Question Detect screen recording

Discussion in 'iOS Questions' started by nwhitfield, May 16, 2018.

  1. nwhitfield

    nwhitfield Active Member Licensed User

    I warn users when they take screenshots in my app that they may be breaching the privacy of other users if they share personal information, using the code from this question

    I would like to also display something if a user tries a screen recording as well. I have found the Technical note from Apple about how to respond, which is here, but I'm still a little unclear on how exactly one creates a listener or checks the value of a property using inline Objective C.

    Any pointers would be much appreciated.

  2. JanPRO

    JanPRO Well-Known Member Licensed User


    you can use the following code snippet:
    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Title = 
    "Page 1"
       Page1.RootPanel.Color = 
    End Sub

    Sub ScreenIsCaptured As Boolean
    Dim no As NativeObject
    Return no.Initialize("UIScreen").RunMethod("mainScreen"Null).GetField("isCaptured").AsBoolean
    End Sub

    Sub SetEvent
    Dim no As NativeObject = Me
    #if OBJC
            - (void)AddEvent {
              [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_capture_change) name:UIScreenCapturedDidChangeNotification object:nil];
    #end if
    End Sub

    Private Sub Capture_Change
    End Sub
    Set the #MinVersion of your App (in the Project Attributes region) to 11+

    Erel, nwhitfield and JordiCP like this.
  3. nwhitfield

    nwhitfield Active Member Licensed User

    Great, thanks.

    Is there a way to make the conditional on the iOS version? I would like to still be able to support people using older devices, like an iPhone 5, which won't ever get beyond iOS 10.
  4. JanPRO

    JanPRO Well-Known Member Licensed User


    I am not 100% sure, but in this case I think it's enough to just the check the OS:
    Dim Version As Float = App.OSVersion
    If Version >= 11 Then SetEvent
    I guess, when the framwork would be completly new, this wouldn't work.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice