I am trying to share Images on Instagram, it's working fine if Instagram is installed on my device, otherwise it will open another app which has the same functionality as Instagram sharing (instead of error throwing).
My Instagram sharing Code is:
let instaFilePath = "instagram://library?AssetPath=\(url!.absoluteString)&InstagramCaption=SocialCommerce"
let instaFilePathURL = URL(string: instaFilePath)
let instagramUrl = URL(string: "instagram://app")
if UIApplication.shared.canOpenURL(instagramUrl!) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(instaFilePathURL!, options: [:], completionHandler: { (completed) in
print("-----------------------(-)--------------------------\(completed)")
})
} else {
self.showMessage("This feature is not available earlier version then iOS 10.0")
}
} else {
self.showMessage("Instagram is not present in your device")
}
I have used CFBundleURLSchemes
and LSApplicationQueriesSchemes
scheme in Info.plist
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>instagram</string>
</array>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
Does anyone have a solution for this? I can't post images to Instagram when Instagram is not installed, I can't even detect if Instagram is installed or not.
Following custom URL Scheme from: https://www.instagram.com/developer/mobile-sharing/iphone-hooks/