Latest 0.9.9
Homepage https://github.com/JPMartha/EggsBenedict
License MIT
Platforms ios 8.0, requires ARC

Build Status Carthage compatible日本語

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

EggsBenedict

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.7.
  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.

CocoaPods

  1. Create a Podfile, and add the following contents:

    use_frameworks!
    pod 'EggsBenedict', '~> 0.9.7'
  2. Run $ pod install in your project directory.

Getting started

  1. On your application Info.plist, add LSApplicationQueriesSchemes key.

    Key Type Value
    LSApplicationQueriesSchemes Array instagram
  2. Create an instance of the SharingFlow class with the SharingFlowType enumeration.

    let sharingFlow = SharingFlow(type: .IGOExclusivegram)

    SharingFlowType enumeration

    According to the Instagram’s documentation, you can use two ways in Instagram’s sharing flow. The SharingFlowType is the enumeration following them.

    • IGPhoto

    Show Instagram plus any other public/jpeg-conforming apps in the application list.

    • IGOExclusivegram (preferred)

    Show only Instagram in the application list. (Actually, some apps are shown.)

  3. Call the presentOpenInMenuWithImage:inView:documentInteractionDelegate:completion: method with two required parameters and two optional parameters.

    sharingFlow.presentOpenInMenuWithImage(YourImage, inView view: YourView, documentInteractionDelegate: nil) { (result) -> Void in
      // Handling Errors
    }

    Parameters

    • image: UIImage!

    The image for sending to Instagram app.

    • view: UIView!

    The view from which to display the menu.

    • delegate: UIDocumentInteractionControllerDelegate?

    The delegate you want to receive document interaction notifications. You may specify nil for this parameter.

    • completion: ((result: Result<Any>) -> Void)?

    The block to execute after the presenting menu. You may specify nil for this parameter.

    • Handling Errors Example

      switch result {
      case .Success(let imagePath):
        print("Success: (imagePath)")
      case .Failure(let error):
        print("Error: (error)")
      }

Remove temporary image file

To remove temporary image file in tmp/ directory, call the removeTemporaryImage: method of the created instance.

  sharingFlow.removeTemporaryImage { (result) -> Void in
      // Handling Errors
  }

Parameters

  • completion: ((result: Result<Any>) -> Void)?

    The block to execute after the removing temporary image file finishes. You may specify nil for this parameter.

    • Handling Errors Example

      switch result {
      case .Success(let imagePath):
        print("Success: (imagePath)")
      case .Failure(let error):
        print("Error: (error)")
      }

Reference

For more information, see EggsBenedict Framework Reference (Swift, iOS).

License

EggsBenedict is released under the MIT License.

Latest podspec

{
    "name": "EggsBenedict",
    "version": "0.9.9",
    "summary": "EggsBenedict is a library for sharing picture on Instagram written in Swift.",
    "description": "This library is following Instagram's sharing flow.nn> __Instagram's documentation__nn> - [Document Interaction](https://www.instagram.com/developer/mobile-sharing/iphone-hooks/#document-interaction)",
    "homepage": "https://github.com/JPMartha/EggsBenedict",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "JPMartha",
    "social_media_url": "https://twitter.com/JPMartha_jp",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/JPMartha/EggsBenedict.git",
        "branch": "develop",
        "tag": "0.9.9"
    },
    "source_files": "EggsBenedict/**/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This