Я хочу поделиться ссылкой на приложение, изображение и текст в Instagram. Возможно ли отобразить предварительно заполненный текст в Instagram? Можно ли поделиться ссылкой на Instagram через приложение iOS? Изображение успешно передано, как поделиться с текстом?
Код:
import UIKit
class ViewController: UIViewController,UIDocumentInteractionControllerDelegate {
private let documentInteractionController = UIDocumentInteractionController()
private let kInstagramURL = "instagram://"
private let kUTI = "com.instagram.photo" //"com.instagram.exclusivegram"
private let kfileNameExtension = "instagram.ig"//"instagram.igo"
private let kAlertViewTitle = "Error"
private let kAlertViewMessage = "Please install the Instagram application"
var imageInstagram = UIImage()
let instagramCaption = String()
func shareToInstaGram() {
let img = UIImage(named: "Logo")
imageInstagram = img!
let instagramURL = NSURL(string: kInstagramURL)
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
let jpgPath = (NSTemporaryDirectory() as NSString).appendingPathComponent(kfileNameExtension)
do {
try imageInstagram.jpegData(compressionQuality: 0.75)?.write(to: URL(fileURLWithPath: jpgPath), options: .atomic)
} catch {
print(error)
}
let rect = CGRect.zero
let fileURL = NSURL.fileURL(withPath: jpgPath)
documentInteractionController.url = fileURL
documentInteractionController.delegate = self
documentInteractionController.uti = kUTI
documentInteractionController.annotation = ["InstagramCaption": "desTitl"]
documentInteractionController.presentOpenInMenu(from: rect, in: view, animated: true)
}
}
}
Как поделиться текстом с пи c?