Skip to content

Latest commit

 

History

History
executable file
·
215 lines (134 loc) · 6.61 KB

SharingFlowClassReference.md

File metadata and controls

executable file
·
215 lines (134 loc) · 6.61 KB

SharingFlow Class Reference

Creating an Instance

  • init(type:)
Declaration
init(type: SharingFlowType)
Parameters
Parameter Description
type A type of SharingFlowType

For more information, see SharingFlowType Enumeration.

==

Presenting Menus

  • presentOpenInMenuWithImage:inView:

Present the menu for sending image to Instagram app.

Declaration
func presentOpenInMenuWithImage(_ image: UIImage!, inView view: UIView!)
Discussion

This method calls the presentOpenInMenuWithImage:inView:documentInteractionDelegate:completion: method setting the delegate parameter and the completion parameter nil.

Availability

Available in 0.9.8 and later.

==

  • presentOpenInMenuWithImage:inView:documentInteractionDelegate:

Present the menu for sending image to Instagram app.

Declaration
func presentOpenInMenuWithImage(_ image: UIImage!,
    inView view: UIView!,
    documentInteractionDelegate delegate: UIDocumentInteractionControllerDelegate?)
Discussion

This method calls the presentOpenInMenuWithImage:inView:documentInteractionDelegate:completion: method setting the completion parameter nil.

Availability

Available in 0.9.8 and later.

==

  • presentOpenInMenuWithImage:inView:completion:

Present the menu for sending image to Instagram app.

Declaration
func presentOpenInMenuWithImage(_ image: UIImage!,
    inView view: UIView!,
    completion: ((sharingFlowResult: SharingFlowResult<String, ErrorType>) -> Void)?)
Discussion

This method calls the presentOpenInMenuWithImage:inView:documentInteractionDelegate:completion: method setting the delegate parameter nil.

Availability

Available in 0.9.8 and later.

==

  • presentOpenInMenuWithImage:inView:documentInteractionDelegate:completion:

Present the menu for sending image to Instagram app.

Declaration
func presentOpenInMenuWithImage(_ image: UIImage!,
    inView view: UIView!,
    documentInteractionDelegate delegate: UIDocumentInteractionControllerDelegate?,
    completion: ((sharingFlowResult: SharingFlowResult<String, ErrorType>) -> Void)?)
Parameters
Parameter Description
image The image for sending to Instagram app.
view The view from which to display the menu.
delegate The delegate you want to receive document interaction notifications. You may specify nil for this parameter.
completion The block to execute after the presenting menu. You may specify nil for this parameter.
Discussion

This method is invoked if the hasInstagramApp property is true. To avoid blocking the main thread, it is invoked asynchronously with Grand Central Dispatch (GCD).

First, write a temporary image file in tmp/ directory. The image data is written to a backup file, and then—assuming no errors occur—the backup file is renamed to the name specified by path. The image file is named jpmarthaeggsbenedict.ig or jpmarthaeggsbenedict.igo according to the SharingFlowType enumeration. For more information, see NSData Class Reference.

Then, call the presentOpenInMenuFromRect:inView:animated: method of an instance of the UIDocumentInteractionController class in main thread.

You can implement a delegate object to track user interactions with menu items displayed by the document interaction controller. For more information, see UIDocumentInteractionControllerDelegate Protocol Reference.

The completion handler is called after the presentOpenInMenuFromRect:inView:animated: method is called of an instance of the UIDocumentInteractionController class.

UIDocumentInteractionController Class Reference

This method displays the options menu asynchronously. The document interaction controller dismisses the menu automatically when the user selects an appropriate option.

Handling Errors Example
sharingFlow.presentOpenInMenuWithImage(YourImage, inView: YourView, documentInteractionDelegate: self) { (sharingFlowResult) -> Void in
    switch sharingFlowResult {
    case .Success(let imagePath):
        print("Success: \(imagePath)")
    case let .Failure(imagePath, errorType):
        print("ImagePath: \(imagePath), ErrorType: \(errorType)")
    }
}

==

Removing Temporary Image

  • removeTemporaryImage

Remove temporary image file in tmp/ directory.

Declaration
func removeTemporaryImage()
Discussion

It is not usually necessary to use this method because this library overwrites an existing file.

This method calls the removeTemporaryImage: method setting the completion parameter nil.

Availability

Available in 0.9.8 and later.

==

  • removeTemporaryImage:

Remove temporary image file in tmp/ directory.

Declaration
func removeTemporaryImage(completionHandler completion: ((sharingFlowResult: SharingFlowResult<String, ErrorType>) -> Void)?)
Parameters
Parameter Description
completion The block to execute after the removing temporary image finishes. You may specify nil for this parameter.
Discussion

It is not usually necessary to use this method because this library overwrites an existing file.

Handling Errors Example
sharingFlow.removeTemporaryImage { (sharingFlowResult) -> Void in
    switch sharingFlowResult {
    case .Success(let imagePath):
        print("Success: \(imagePath)")
    case let .Failure(imagePath, errorType):
        print("ImagePath: \(imagePath), ErrorType: \(errorType)")
    }
}

==

Accessing the Device Attributes

  • hasInstagramApp

Returns a Boolean value indicating whether or not Instagram app is installed on the iOS device.

Declaration
var hasInstagramApp: Bool { get }
Discussion

If true, the iOS device has Instagram app; otherwise it does not.