[我正尝试从IOS应用共享instagram上的URL,文本和图像。我可以共享图像,但不能共享文本和URL。然后我阅读了有关instagram政策的信息,根据这篇文章,他们不允许再分享文本了。这是a link!所以现在我决定将文本消息和URL分享到instagram Direct。我已经在Instagram开发文档中找到了URL方案,但是关于共享指向没有一个词。我还检查了一些第三方库-没有帮助。
[这是我尝试共享的代码。.但是InstagramCaption无法正常工作。
class InstagramManager: NSObject,
UIDocumentInteractionControllerDelegate {
private let kInstagramURL = "instagram://app"
private let kUTI = "com.instagram.exclusivegram"
private let kfileNameExtension = "instagram.igo"
private let kAlertViewTitle = "Error"
private let kAlertViewMessage = "Please install the Instagram
application"
var documentInteractionController =
UIDocumentInteractionController()
// singleton manager
class var sharedManager: InstagramManager {
struct Singleton {
static let instance = InstagramManager()
}
return Singleton.instance
}
func postImageToInstagramWithCaption(imageInstagram: UIImage,
instagramCaption: String, view: UIView) {
// called to post image with caption to the instagram
application
let instagramURL = NSURL(string: kInstagramURL)
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
let jpgPath = (NSTemporaryDirectory() as
NSString).appendingPathComponent(kfileNameExtension)
do {
try
imageInstagram.jpegData(compressionQuality:1.0)?.write(to:
URL(fileURLWithPath: jpgPath), options: .atomic)
} catch {
print(error)
}
let rect = CGRect(x: 0, y: 0, width: 612, height: 612)
let fileURL = NSURL.fileURL(withPath: jpgPath)
documentInteractionController.url = fileURL
documentInteractionController.delegate = self
documentInteractionController.uti = kUTI
// adding caption for the image
documentInteractionController.annotation =
["InstagramCaption": instagramCaption]
documentInteractionController.presentOpenInMenu(from: rect,
in: view, animated: true)
} else {
Utilities.showAlert(kAlertViewTitle, withMessage:
kAlertViewMessage)
}
}
}
如果有什么可以引导我的。.i-e在新闻源或直接消息中共享Text + URL + Image
您如何直接分享图像?