TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Reply to this topic…

You need to create an account or log in to reply.

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.