Reputation: 115
I'm wondering if it is possible to share media file using URL to Instagram. Basically I made application capturing picture and video in my own app, and I shared it to other apps. And I used "instagram://library?LocalIdentifier=" + asset.localIdentifier
, and the type of asset
is PHAsset
. But I want to share media file to instagram before saving to Album of real device. If i will do this, i should use URL, not PHAsset
. Do you think there is only one way i can share media file using URL that i should save file and get PHAsset
from device? If you don't, how can I set parameter of instagram://library
to use file url? Please let me know.
And also in official documentation, there is no explanation about library
parameter. Does it mean that parameter can be removed someday?
Thank you!
Upvotes: 0
Views: 1481
Reputation: 10112
You can share a photo without saving it into Photos Library using UIDocumentInteractionController
let documentInteractionController = UIDocumentInteractionController(url: url)
documentInteractionController.name = fileName
documentInteractionController.presentPreview(animated: true)
Sharing to Instagram Feed - Copy pasting relevant content below in case link goes dead later.
Document Interaction
If your application creates photos and you'd like your users to share these photos using Instagram, you can use the Document Interaction API to open your photo in Instagram's sharing flow.
You must first save your file in PNG or JPEG (preferred) format and use the filename extension
.ig
. Using the iOS Document Interaction APIs you can trigger the photo to be opened by Instagram. The Identifier for our Document Interaction UTI iscom.instagram.photo
, and it conforms to thepublic/jpeg
andpublic/png
UTIs. See the Apple documentation articles: Previewing and Opening Files and the UIDocumentInteractionController Class Reference for more information.Alternatively, if you want to show only Instagram in the application list (instead of Instagram plus any other public/jpeg-conforming apps) you can specify the extension class
igo
, which is of typecom.instagram.exclusivegram
.When triggered, Instagram will immediately present the user with our filter screen. The image is preloaded and sized appropriately for Instagram. For best results, Instagram prefers opening a JPEG that is 640px by 640px square. If the image is larger, it will be resized dynamically.
Upvotes: 1