JayantBadlani / ScreenShield

ScreenShield is an iOS library that provides a simple way to protect your app's content from being captured or recorded by screenshots, screen recordings, or other screen capture methods. It works by adding a secure layer on top of your views, which prevents most screen capture mechanisms from recording the underlying content.
MIT License
113 stars 18 forks source link

Alert message Not hidden in SwiftUI #9

Closed Prathap-Aosta closed 7 months ago

Prathap-Aosta commented 7 months ago
  1. After the alert popup was displayed, I took a screenshot, but the alert message was not hidden. Simulator Screenshot - iPhone 15 Pro Max - 2024-03-27 at 13 15 14

  2. Native iOS Menu popup was displayed, I took a screenshot, but the menu was not hidden. Simulator Screenshot - iPhone 15 Pro Max - 2024-03-27 at 16 24 19

import SwiftUI import ScreenShield

struct ContentView: View { @State private var presentAlert = false @State private var menutext = "" @State private var arrayMenuVal = ["Apple", "Orange", "Mango", "Grape"]

var body: some View {
    ZStack{
        Color.red.ignoresSafeArea()

    VStack {
        Text("Sensative Information")
            .padding(.bottom, 50)
            .font(.title)
        Image("sensitive1")
            .resizable()
            .frame(maxWidth: .infinity)
            .aspectRatio(contentMode: .fit)

        Menu {
            ForEach(arrayMenuVal, id: \.self){ val in
                Button("\(val)") {
                    menutext = val
                }
            }
        } label: {
            TextField(text: $menutext, label: {
                Text("Menu")
                    .foregroundColor(.white)
                    .font(.footnote)
            })
        }
        .padding(.top, 20)

        Button("Alert popup") {
            presentAlert = true
        }
        .font(.footnote)
        .foregroundColor(.white)
        .buttonBorderShape(ButtonBorderShape.capsule)
        .padding(.top, 30)
    }
    .alert(isPresented: $presentAlert) {
        Alert(title: Text("Test for screenshot"))
    }
}
    .padding()
    .protectScreenshot()
    .onAppear {
        ScreenShield.shared.protectFromScreenRecording()
    }
}

}

JayantBadlani commented 7 months ago

@Prathap-Aosta, It's not possible to hide the native OS alerts and menu that appear on a separate layer of the view. If you want to hide the alerts, create your custom alerts.

Prathap-Aosta commented 5 months ago

@JayantBadlani Okay, Thanks