EggsBenedict is a library for sharing picture with Instagram app written in Swift.
This library is following Instagram's sharing flow.
Instagram's documentation
If the custom URL schemes instagram://
can be opened direct users on the iOS device, the flow is as follows.
- Save temporary image file named
jpmarthaeggsbenedict
(JPEG format) intmp/
directory using the filename extension.ig
or.igo
. - Display the menu for copying to Instagram app.
- If users tap the "Copy to Instagram" icon, open Instagram app with its 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.
The reason is because I like Eggs Benedict 😋
- Swift 2.1
- Xcode 7.2
- iOS 8.0 and later
Carthage (preferred)
- Create a Cartfile, and add
github "JPMartha/EggsBenedict" ~> 0.9.9
. - Run
$ carthage update --platform iOS
in your project directory. - On your application targets’ “Build Phases” settings tab, in the “Link Binary With Libraries” section, click the “+” icon and add
EggsBenedict.framework
from the Carthage/Build folder on disk. - On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:
/usr/local/bin/carthage copy-frameworks
and add the "Input Files" to EggsBenedict.framework:
$(SRCROOT)/Carthage/Build/iOS/EggsBenedict.framework
This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files are copied when archiving.
- Create a Podfile, and add the following contents:
use_frameworks!
pod 'EggsBenedict', '~> 0.9.9'
- Run
$ pod install
in your project directory.
- On your application Info.plist, add
LSApplicationQueriesSchemes
key.
Key | Type | Value |
---|---|---|
LSApplicationQueriesSchemes | Array |
- Create an instance of the
SharingFlow
class with theSharingFlowType
enumeration.
let sharingFlow = SharingFlow(type: .IGOExclusivegram)
For more information, see SharingFlow Class Reference and SharingFlowType Enumeration.
- Call the
presentOpenInMenuWithImage:inView:
of the created instance.
sharingFlow.presentOpenInMenuWithImage(YourImage, inView view: YourView)
For more information, see SharingFlow Class Reference.
EggsBenedict is released under the MIT License.