Joe
Joe

Reputation: 3961

Opening Instagram App in Swift, with a custom URL Scheme

There's a button in my project that opens Instagram when tapped. The problem is I need this button to open Instagram, and if the user was in the middle of editing a photo, it takes them right back to the photo editing tab.

With my code below, the button takes the user to Instagram's main feed. If they were in the middle of editing a photo, it clears that out.

Is there a custom URL scheme that will open Instagram, without 'erasing' any progress the user was currently working on? EG - writing their image description, or editing their image with filters.

// Instagram button pressed:

let urlStr: String = "instagram://app"
let url = URL(string: urlStr)
if UIApplication.shared.canOpenURL(url!) {
    print("can open")
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url!, options: [:], completionHandler: nil)
    } else {
        UIApplication.shared.openURL(url!)
    }
}

I also tried "instagram://" and "instagram://camera" - but the problem persists of clearing out the screen that the user was currently working on.

Thanks in advance

Upvotes: 3

Views: 13899

Answers (1)

ramacode
ramacode

Reputation: 924

According to Instagram iPhone Hooks documentation, there is no URL scheme for editing a photo.

source : https://developers.facebook.com/docs/instagram/sharing-to-feed/

Upvotes: 4

Related Questions