UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Determine if ShareLink was successful or not.

Forums > SwiftUI

Does anyone know if the new ShareLink has an onDismiss or some sort of completion handler. I've been unable to find one and wasn't sure if I was missing something?

What I'm trying to do is determine when the share sheet the ShareLink brings up gets cancelled or the user chose to share whatever your sharing. I just need to know if I shared or cancelled, because i need to do something based on being successful. I need to update coredata and dismiss the sheet. The only thing i can come up with is the following, just not sure its a good solution?

ShareLink(item: urlForProgramsPDF(), subject: Text(LocalizedAppConstants.emailSubject), message: Text(createEmailMessageBody()))
  .onReceive(timer) { _ in
      // The only way I could get the view to dismiss. I give 10 seconds
      // and then the view will dismiss
      if progress < 10 {
          progress += 1
      } else {
          dismiss()
      }
  }

Thanks,

Taz

1      

Does anyone know if you can detect if the sharelink was successful, I need to be able to determine that if possible?

1      

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!

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.