I am now working with the new SwiftUI 4.0 and using the new ShareLink feature . How can I know if a link or text has been shared successfully, any suggestions would be great ? I have a simple ShareLink like this
ShareLink(item: InviteMessage) {
Text("Test Share")
.foregroundColor(.black)
}
before in SwiftUI 3.0 I would use this code
.background(SharingViewController(isPresenting: $InviteOthers) {
let message = "Share Me"
let av = UIActivityViewController(activityItems: [message], applicationActivities: nil)
av.completionWithItemsHandler = { (activity, success, items, error) in
if success {
// shared successfully update count
}
}
return av
})
It doesn't seem possible to know if the content has been shared successfully, but you can at least detect if the link has been clicked with the simultaneousGesture modifier (onTapGesture doesn't work on ShareLink):
ShareLink(){}
.simultaneousGesture(TapGesture().onEnded() {
print("clicked")
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With