I have an iOS Xcode 7 Swift 2 project I’m working on. The app posts photos to Facebook
and Twitter
using:
var shareToFacebook: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
and
var shareToTwitter: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
Love how easy and simple for just posting a photo to these two social medias. I didn’t need or want the APIs for them.
I want to do something similar and simple for Instagram
. What is the best way to do this without having to deal with Instagram API
? Or do I have no choice?
My photo data
is saved using NSCoding
, not in the DocumentDirectory
. I looked here for integration but this is for a photo saved in the app directory
.
Just something simple like what I already have for Facebook and Twitter.
3
Answers
I looked here and found a solution:
I created an
NSObject
:Then in my
@IBAction
I used:This opens bring a menu up with the 'open-in' style and the user can open the app in
Instagram
(if installed).Updated for Swift 3
and then in the ViewController you want to call it in…
This opens the ‘open-in’ function if Instagram is installed
Here is a reusable class with swift 4+. Working in Xcode 10.1.
copy and paste the below code into the file.
And use of this function in ViewController class.