BLACK FRIDAY SALE: Save big on all my Swift books and bundles! >>

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 {




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


Hacking with Swift is sponsored by RevenueCat

SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.

Learn more

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.