iOS Branding Basics
SDK provides a Branding
object, which allows customization of all aspects of branding:
- Colors (via the
BrandingColorsProvider
protocol) - Fonts (via the
BrandingFontsProvider
protocol) - Images (via the
BrandingImagesProvider
protocol) - Strings and localization (via the
BrandingL10NProvider
protocol)
The Branding
object is always initialized with default implementation for all protocols, which provides a flexibility that allows the integrator to customize only the aspects they care about:
If custom implementations are not provided for some provider protocols, default implementations will be used.
If a custom implementation is provided, it does not need to implement all properties. The default protocol implementation will be used for any properties not provided by your custom implementation.
For example an integrator can override all colors, stay with defaults for all fonts, and only override some images.
Finally, Branding does not have specific requirements on how colors, fonts, and images are stored in the app. For example some developers may use assets to store colors, while others prefer a programmatic way of defining the colors. Because integrators implement the protocols, they can choose how and where various customization entities are stored.
Full SDK and Capture Flow use cases utilize Branding
object directly.
Standalone Capture allows the additional level of customization, with the Capture.RuntimeSettings
(covered in Customization
section of the Launch Capture page).
Steps:
- Create custom implementation for one or more Branding providers.
- Create the instance of
Branding
. - Customize some or all aspects of the branding by using custom providers.
- Pass the created
Branding
instance to theSensibillSDK.Configuration
(for use with Full SDK or Capture Flow) orCapture.RuntimeSettings
, created for a specified document type (for use with Standalone Capture) - Follow Starting SDK or Launch Capture steps to continue the startup process for the corresponding use case.
// 1. Create custom implementation for one or more Branding providers
class MyColors: BrandingColorsProvider {
// ...
}
// 2. Create Branding object
let branding = Branding()
// 3. Customize some or all aspects of the branding
branding.colors = MyColors()
// ...
// 4. Pass the created Branding object to the SensibillSDK.Configuration (Full SDK, Capture Flow), e.g.:
let configuration = SensibillSDK.Configuration(
environment: .beta,
branding: branding
)
// ... or pass a created Branding object to the Capture.RuntimeSettings (Standalone Capture), e.g.:
let receiptRuntimeSettings = Capture.RuntimeSettings.receipt(branding: branding)
Usage with Objective-C
While Branding
itself is available in Objective-C as SBLBranding
, direct access to branding provider protocols is not possible as they use SwiftUI structures, such as Color
, or Font
. Instead, use the following steps:
- Create an instance of
SBLBrandingBridge
- Customize colors, fonts, etc in the created bridge instance. Note that the bridge uses UIKit equivalents of SwiftUI structures (e.g.
UIColor
instead ofColor
) - Convert the bridge to
SBLBranding
usingconvertToBranding
function of the bridge. - Create an instance of
SBLCaptureFeatureFlags
. Optionally you can customize them. - Create an instance of
SBLCaptureRuntimeSettings
for a selected document type (receipt or invoice) - Pass the created
SBLCaptureRuntimeSettings
instance toSBLCaptureNavigationController
- Present the Capture
// 1. Create an SBLBrandingBridge object
SBLBrandingBridge * bridge = [[SBLBrandingBridge alloc] init];
// 2. Customize colors, fonts, etc
bridge.colors.primary = [UIColor colorWithRed:0.6 green:0.8 blue:1.0 alpha:1.0]
// 3. Convert the bridge to SBLBranding
SBLBranding * branding = [bridge convertToBranding];
// 4. Create an instance of SBLCaptureFeatureFlags.
SBLCaptureFeatureFlags * featureFlags = [[SBLCaptureFeatureFlags alloc]init];
// 5. Create an instance of SBLCaptureRuntimeSettings
SBLCaptureRuntimeSettings * runtimeSettings = [SBLCaptureRuntimeSettings receiptWithBranding:branding featureFlags:featureFlags];
// 6. Pass the created SBLCaptureRuntimeSettings to SBLCaptureNavigationController
SBLCaptureNavigationController *capture = [[SBLCaptureNavigationController alloc] initWithSettings:captureRuntimeSettings];
// 7. Present the Capture
// ...