Skip to main content

Configuration

Initial screen (entry point) selection

By default the built-in gallery will be shown first after the presentation of the Photo Editor. In some cases the hosting app may already provide the photo selection functionality using its own custom gallery and it is necessary to directly open the photo editing screen with a preselected photo. To support such use cases there is the entryPoint property in PhotoEditorLaunchConfig. By using the editorWithImage or editorWithURL options you can specify the edited image by directly providing either the UIImage instance or the local URL to the on-disk binary image representation.

In the following example the image stored in the app's bundle will be opened in the Photo Editor SDK:

let url = Bundle.main.url(forResource: "image", withExtension: "jpg")!
let launchConfig = PhotoEditorLaunchConfig(
hostController: ...,
entryPoint: .editorWithURL(url)
)
photoEditorSDK.presentPhotoEditor(
withLaunchConfiguration: launchConfig,
completion: nil
)

Should there be any problem with decoding the image at the provided url, an error message will be logged into the console by the SDK.

Configuration of the sharing screen

After finishing editing an image, a user is navigated to the Sharing screen. If Facebook or Instagram is installed on the user's phone, it will be possible to present an option to share the image as a Facebook or Instagram Story. To enable such a functionality you need to specify the Facebook app id:

var configuration = PhotoEditorConfig() 
configuration.previewScreenMode = .enabled(
previewScreenConfiguration: .init(
shareButtonsMode: .enabled(
shareButtonsConfiguration: .init(facebookId: "1234567890")
)
)
)
let photoEditorSDK = BanubaPhotoEditor(
token: "***",
configuration: configuration
)

Read more about sharing to Instagram and Facebook stories at https://developers.facebook.com/docs/instagram/sharing-to-stories/. The sharing screen can be disabled entirely. In such case a user will be redirected back to your hosting app after tapping the "Save" button at image editing screen:

var configuration = PhotoEditorConfig() 
configuration.previewScreenMode = .disabled

Alternatively, you can also hide the social networks sharing buttons while keeping the sharing screen:

var configuration = PhotoEditorConfig() 
configuration.previewScreenMode = .enabled(
previewScreenConfiguration: .init(shareButtonsMode: .disabled)
)

Configuration of the image editing screen

To prevent the automatic saving of final edited image to the user's photo library set false to saveResultToPhotoLibrary in EditorScreenConfiguration:

var configuration = PhotoEditorConfig()
configuration.editorScreenConfiguration = .init(saveResultToPhotoLibrary: false)