Skip to content

Latest commit

 

History

History
91 lines (72 loc) · 3.32 KB

quickstart_pe_ios.md

File metadata and controls

91 lines (72 loc) · 3.32 KB

iOS Photo Editor SDK quickstart

This guide demonstrates how to quickly integrate iOS Photo Editor SDK into your Flutter project. The main part of an integration and customization is implemented in ios directory in your Flutter project using native iOS development process.

Once complete you will be able to launch photo editor in your Flutter project.

Installation

Add iOS Photo Editor SDK dependencies to your Podfile

  # Photo Editor
  pod 'BanubaPhotoEditorSDK', '1.2.3'

Configuration

Create new Swift class PhotoEditorModule in your project for initializing and customizing Photo Editor SDK features.

Launch

Flutter platform channels approach is used for communication between Flutter and iOS.

Set up channel message handler in your AppDelegate to listen to calls from Flutter.

    let binaryMessenger = controller as? FlutterBinaryMessenger {
            
    let channel = FlutterMethodChannel(
        name: AppDelegate.channelName,
        binaryMessenger: binaryMessenger
    )
            
     channel.setMethodCallHandler { methodCall, result in
        ... 
     }

Send initPhotoEditor message from Flutter to Android for initializing Photo Editor SDK:

await platformChannel.invokeMethod(methodInitPhotoEditor, LICENSE_TOKEN);

where initialize Photo Editor using the license token and PhotoEditorConfig

    let photoEditorSDK = BanubaPhotoEditor(
        token: token,
        configuration: PhotoEditorConfig()
    )

Send startPhotoEditor message from Flutter to iOS

  dynamic result = await platformChannel.invokeMethod('startPhotoEditor');

and add corresponding handler on iOS side to start Photo Editor Photo Editor in PhotoEditorModule.

+ let launchConfig = PhotoEditorLaunchConfig(
    hostController: controller,
    entryPoint: .gallery
  )
  
  photoEditorSDK?.delegate = self
        
  photoEditorSDK?.getLicenseState(completion: { [weak self] isValid in
    guard let self else { return }
    if isValid {
      print("✅ License is active, all good")
+      photoEditorSDK?.presentPhotoEditor(
        withLaunchConfiguration: launchConfig,
        completion: nil
      )
    } else {
      print("❌ License is either revoked or expired")
    }
  })

Important

  1. Instance photoEditorSDK is nil if the license token is incorrect. In this case you cannot use photo editor. Check your license token.
  2. It is highly recommended to check if the license if active before starting Photo Editor.

What is next?

This quickstart guide has just covered how to quickly integrate iOS Photo Editor SDK, it is considered you managed to start photo editor from your Flutter project.

Please check out docs to know more about the SDK and complete full integration.