Skip to main content

Hybrid integration

In a hybrid integration, your native UI handles menus, product lists and shade pickers, while the PulpoAR plugin in a WebView only renders the try-on. Native code and the WebView talk through the same JavaScript bridge as a WebView integration.

Use it when you want native controls but don't use the native SDK.

┌─────────────────────────────────────┐
│ Native UI layer │
│ (menus, products, variants) │
└──────────────┬──────────────────────┘
│ actions ▼ ▲ events
┌──────────────┴──────────────────────┐
│ WebView + JavaScript bridge │
└──────────────┬──────────────────────┘
│
┌──────────────┴──────────────────────┐
│ PulpoAR plugin (try-on engine) │
└─────────────────────────────────────┘

Complete example: swift-hybrid-ui-example

1. Load the plugin without its UI​

Choose how much of the built-in UI to hide:

URLResult
https://plugin.pulpoar.com/vto/<project-key>?custom=trueFully native UI. The built-in catalog, opacity slider and before/after slider are hidden.
https://plugin.pulpoar.com/vto/<project-key>?catalog=falseNative product selection only. The built-in sliders and controls stay.

See URL parameters.

2. Build your UI from the catalog​

The onReady event returns your project data, including variants, products and categories. Use it to build your native menus.

let events = Events(onReady: { appData in
// Only variants with a slug can be applied
let variants = appData.variants
.filter { $0.slug != nil }
.unique { $0.id == $1.id }

// Only show categories that have at least one usable variant
let categories = appData.categories.filter { category in
variants.contains { $0.product.category.id == category.id }
}
})

Product images are file IDs. Build the image URL with the API prefix:

let imageUrl = "https://api.pulpoar.com/assets/\(product.image)"

You can also load your catalog from your own backend or the Partner API.

3. Drive the try-on from native controls​

Call SDK actions in the WebView when the user taps your controls:

let sdk = PulpoARSDK(webView: webView)

// Live camera
sdk.initCamera(mode: ["facingMode": "user"])
sdk.setPath("apply-live")

// Apply the tapped shade
sdk.applyVariants(["lipstick-red-001"])

// Photo mode with a model image
sdk.setImageToApply("https://example.com/model.png")
sdk.setPath("apply-photo")

Under the hood, each call runs JavaScript in the WebView, for example pulpoar.applyVariants(["lipstick-red-001"]).

Common actions and events​

ActionPurpose
setPathSwitch between live camera, photo and model screens
applyVariantsApply shades by slug
setImageToApplyUse a photo or model image
initCameraStart the front or back camera
EventPurpose
onReadyCatalog data for building your UI
onPathChangeKeep your UI in sync with the current screen
onAppliedVariantsChangeHighlight the applied shades
onErrorShow an error state

Hybrid vs native SDK​

HybridNative SDK (Try-On Kit)
RenderingWeb engine in a WebViewNative engine
PerformanceGoodBest
Agreement neededNoYes
PlatformsAny platform with a WebViewiOS, Android