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.

    Nigel
     
  2. JanPRO

    JanPRO Well-Known Member Licensed User

    Hi,

    you can use the following code snippet:
    Code:
    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Initialize(
    "Page1")
       Page1.Title = 
    "Page 1"
       Page1.RootPanel.Color = 
    Colors.White
       NavControl.ShowPage(Page1)
       SetEvent
    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
        no.RunMethod(
    "AddEvent"Null)
        
    #if OBJC
            - (void)AddEvent {
              [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_capture_change) name:UIScreenCapturedDidChangeNotification object:nil];
            }
        
    #end if
    End Sub

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

    Jan
     
    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

    Hi,

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

    Jan
     
Loading...
  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