I have created this Share Button that has items to share like an URL and a Text.
When i hit the Share Button though it only shows the Text to share but not the URL.
How does one select precedence of the URL over the text? Such that when sharing to Facebook it only takes the URL, but when posting to Twitter it uses the URL as well as the Text ?
import SwiftUI
struct ShareButton: View {
@State private var isShareSheetShowing = false
var url : String = "https://apple.com"
var body: some View {
Button(action: shareButton){
Image(systemName: "square.and.arrow.up")
.frame(width: 35, height: 35)
}
}
func shareButton() {
isShareSheetShowing.toggle()
let items: [Any] = [URL(string: url)!, "Visit the Apple Website Text"]
let av = UIActivityViewController(activityItems: items, applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController!.present(av, animated: true, completion: nil)
}
}
struct ShareButton_Previews: PreviewProvider {
static var previews: some View {
ShareButton()
}
}