2

Im trying to share a Instagram post from an app that I made in swiftUI using UIActivityView, but whenever I try to share it only the picture shows up and the caption doesn't. The same thing happens with Facebook.

func sharePost(){
        isSheetShowing.toggle()
        let caption = "Hello, world!"

        if let image = UIImage(named: "Image") {

            let vc = UIActivityViewController(activityItems: [image,caption], applicationActivities: nil)

            UIApplication.shared.windows.first?.rootViewController?.present(vc,animated : true)
        }
    }
  • As far as I know you can't pass a text to Instagram. Maybe try only passing an image. Let me know! :) – RedX May 20 '20 at 20:22

1 Answers1

0

UIActivityController needs to correctly recognize what exactly you are trying to share in order to display it corrrectly. This solution seems to answer your question directly.

Also, this is kind of an anti-pattern in SwiftUI (presenting it directly on the window). You should check this question out.

lennartk
  • 570
  • 1
  • 4
  • 15