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:
| URL | Result |
|---|---|
https://plugin.pulpoar.com/vto/<project-key>?custom=true | Fully native UI. The built-in catalog, opacity slider and before/after slider are hidden. |
https://plugin.pulpoar.com/vto/<project-key>?catalog=false | Native 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
| Action | Purpose |
|---|---|
setPath | Switch between live camera, photo and model screens |
applyVariants | Apply shades by slug |
setImageToApply | Use a photo or model image |
initCamera | Start the front or back camera |
| Event | Purpose |
|---|---|
onReady | Catalog data for building your UI |
onPathChange | Keep your UI in sync with the current screen |
onAppliedVariantsChange | Highlight the applied shades |
onError | Show an error state |
Hybrid vs native SDK
| Hybrid | Native SDK (Try-On Kit) | |
|---|---|---|
| Rendering | Web engine in a WebView | Native engine |
| Performance | Good | Best |
| Agreement needed | No | Yes |
| Platforms | Any platform with a WebView | iOS, Android |