LAST CHANCE: Save 50% on all my Swift books and bundles! >>

Screenshot Function not working

Forums > Swift

Hi,

I have the following code in my app to detect when a screenshot is taken by a user:

.onReceive(NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification)) { _ in Task { do { try await genFs.Save_Screenshot(RecipID: appService.Their_B_Prof.first?.UserID as? String ?? "BProfLk", RecipFirstN: passProfInfo.TheirFirstN_Swipe) } catch { print("Error: (error.localizedDescription)")

                }
            }
        }

In the XCode simulator, it takes a screenshot and shows the proper imate, but when I use it on my actual phone it just shows a white screen. Any thoughts on the cause of this?

2      

Sorry, I see that now, it didn't pickup the first piece which starts with .onRecieve

.onReceive(NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification)) { _ in Task { do { try await genFs.Save_Screenshot(RecipID: appService.Their_B_Prof.first?.UserID as? String ?? "BProfLk", RecipFirstN: passProfInfo.TheirFirstN_Swipe) } catch { print("Error: (error.localizedDescription)") } } }

2      

Please return to your ORIGINAL post and follow directions found here.

See -> Posting Code Snips

3      

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.