/EggsBenedict

EggsBenedict is a library for sharing picture on Instagram written in Swift.

Primary LanguageSwiftMIT LicenseMIT

EggsBenedict

Build Status Carthage compatible 日本語

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.

  1. Save temporary image file named jpmarthaeggsbenedict (JPEG format) in tmp/ directory using the filename extension .ig or .igo.
  2. Display the menu for copying to Instagram app.
  3. 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.

- By the way, why was it named "EggsBenedict"?

The reason is because I like Eggs Benedict 😋

Availability

  • Swift 2.1
  • Xcode 7.2
  • iOS 8.0 and later

Adding EggsBenedict.framework to your project

Carthage (preferred)

  1. Create a Cartfile, and add github "JPMartha/EggsBenedict" ~> 0.9.9.
  2. Run $ carthage update --platform iOS in your project directory.
  3. 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.
  4. 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.

  1. Create a Podfile, and add the following contents:
use_frameworks!
pod 'EggsBenedict', '~> 0.9.9'
  1. Run $ pod install in your project directory.

Getting started

  1. On your application Info.plist, add LSApplicationQueriesSchemes key.
Key Type Value
LSApplicationQueriesSchemes Array instagram
  1. Create an instance of the SharingFlow class with the SharingFlowType enumeration.
let sharingFlow = SharingFlow(type: .IGOExclusivegram)

For more information, see SharingFlow Class Reference and SharingFlowType Enumeration.

  1. Call the presentOpenInMenuWithImage:inView: of the created instance.
sharingFlow.presentOpenInMenuWithImage(YourImage, inView view: YourView)

For more information, see SharingFlow Class Reference.

Documentation

License

EggsBenedict is released under the MIT License.