class ShareSheetViewModel: UIViewController, ObservableObject, SharingDelegate {
func sharer(_ sharer: Sharing, didCompleteWithResults results: [String : Any]) {
if sharer.shareContent?.pageID != nil {
print("Share: Success")
}
}
func sharer(_ sharer: Sharing, didFailWithError error: Error) {
print("Share: Fail")
}
func sharerDidCancel(_ sharer: Sharing) {
print("Share: Cancel")
}
func actionFB(){
let shareContent = ShareLinkContent()
shareContent.contentURL = URL.init(string: "https://developers.facebook.com")! //your link
shareContent.quote = "Text to be shared"
let dialog = ShareDialog(viewController: self, content: shareContent, delegate: self
)
dialog.show()
}
}
ShareSheetViewModel.swift
Button(action: {
filterVM.actionFB()
}, label: {
Group{
HStack {
Image("FbIcon")
.resizable()
.frame(width: 20, height: 20)
Text("Facebook")
.font(.custom("PublicSans-Regular", size: 14))
.foregroundColor(.white)
.padding(.leading, 8)
Spacer()
}
.padding(.horizontal, 16)
}
})
ShareComponent.swift
I can't share link my url to the Facebook app directly.
Is there a solution for my issue?
reference : Share on Facebook IOS 11 Swift