Skip to main content

ReactNative API References

Initialization Method​

To get started, call the GlamAr.init method. This adds the GlamAr SDK into the target container and configures it with the provided Access key and optional configuration.

const config: GlamArConfig = {
accessKey: "YOUR_ACCESS_KEY", // Requried
meta: {
preloadMLModels: ["face", "hair", "hand", "light"],
},
};
GlamAr.init(config);

Initialization Config​

ParametersTypeDescriptionOptions
accessKeystringPass your unique Access Key
categorystringPass any compatible subcategory

sunglasses, necklace, earrings etc.
Check supported subcategories

meta.preloadMLModelsstring[]Downloads the listed ML models during SDK initialization.["face", "hair", "hand", "light"]

Example​

const config: GlamArConfig = {
accessKey: "YOUR_ACCESS_KEY", // Requried
category: "Any Sub cateogory", // sunglasses , earring , hats (optional)
meta: {
preloadMLModels: ["face", "hair", "hand", "light"],
},
};

GlamAr.init(accessKey, config);

Sku config​

Our SDK currently processes sku's in two formats:

  • Id : This is an unique id we give to every SKU created with GlamAR console < Product Inventory. You can check the sku-id in the inventory under column SKU ID
  • Config : This is an object that can be created using the exsisting SKU in your inventory.

Any SKU config must contain 4 key item

{
category: "desired-category", // `eyeware`,`jewellery`,`accessories` etc.
subCategory: "desired-subCategory", // `sunglasses`, `necklace`, `earring`
status: "PUBLISHED",
arEffect:{
// Copy this entire object as it contains all the necessary rendering data we need to show the desired SKU as custimized in the console
}
}

You can also add in 'productName' and 'productImage' properties in the object. These will be used in displaying SKU in our SKU selection area at the bottom.

We provide a Model Viewer for viewing your model in 3D. It supports displaying the dimensions of model, if provided to it. These dimensions are shown in 'cm' measurment. To use this feature, you can add a meta tag inside your object. Example:

{
category: "eyeware",
subCategory: "sunglasses",
status: "PUBLISHED",
arEffect:{
// Details
}
meta:{
dimensions: {
length: "length-of-model",
width: "width-of-model",
height: "height-of-model",
},
}
}
ParametersTypeDescription
categorystringeyeware, makeup, jewellery etc.
subCategorystringsunglasses, necklace, earrings etc.
productNamestringName for the product
productImagestringImage URL for the product
arEffectArEffectOptionsObject contains data that is used to render model accurately
metaMetaOptionsObject contains miscellaneous data

ArEffectOptions​

ParametersTypeDescription
transformobjectContains position and rotation settings
envSettingsobjectContains lighting and environment settings
effectAssets2Dstring[]Contains urls of images for SKU rendering
effectAssets3DEffectAssets3DOptionsContains url of 3D file for rendering

EffectAssets3DOptions​

ParametersTypeDescription
idstringAlways send "full"
urlstring

Valid url to the desired asset. Supported extension is .glb and .txt

MetaOptions​

ParametersTypeDescription
dimensionsobjectContains length, width and height properties

Post-Initialization Methods​

applyBySku​

GlamAr.applyBySku(skuId, callback);

Load a virtual try-on using applyBySku method and passing the relevant SKU Id.
Return Value: None

ParametersTypeDescription
SKU Idstring A SKU ID.
callbackfunctionfunction, fires after the Sku is applied

applyByCategory​

Loads the product catalog for a supported category. Pass optional catalog settings to filter the products by storefront.

GlamAr.applyByCategory("eyewear");
GlamAr.applyByCategory("eyewear", { storeFront: "store_a" });
ParameterTypeDescription
categorystringRequired. A supported category, such as eyewear. See supported categories and subcategories.
optionsApplyCatalogOptionsOptional catalog settings.
options.storeFrontstringOptional storefront filter. Use the exact key storeFront and a nonblank storefront value.

Omit options to load the catalog without a storefront filter. An explicitly empty or whitespace-only storeFront is rejected. Returns no value.

applyBySubCategory​

Loads the product catalog for a supported subcategory. Pass optional catalog settings to filter the products by storefront.

GlamAr.applyBySubCategory("sunglasses");
GlamAr.applyBySubCategory("sunglasses", { storeFront: "store_a" });
ParameterTypeDescription
subCategorystringRequired. A supported subcategory, such as sunglasses. See supported categories and subcategories.
optionsApplyCatalogOptionsOptional catalog settings.
options.storeFrontstringOptional storefront filter. Use the exact key storeFront and a nonblank storefront value.

Omit options to load the catalog without a storefront filter. An explicitly empty or whitespace-only storeFront is rejected. Returns no value.

applyMultipleConfigData​

GlamAr.applyMultipleConfigData(skuConfigArray);

Display multiple SKU types at once. The input should be an array of sku configs. Each item can be of diffrent subcategory eg: sunglasses, caps, earrings, etc.
Return Value: None

ParametersTypeDescription
skuConfigArrayobjectAn Array of SKU Configs

Following is an example of above skuConfigArray for applyMultipleConfigData.

const data = [
{
category: "eyewear",
subCategory: "eyeglasses",
status: "PUBLISHED",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
},
{
category: "accessories",
subCategory: "caps",
status: "PUBLISHED",
productName: "Test cap",
productImage:
"https://cdn.pixelbin.io/v2/dummy-cloudname/original/05-DP1YgvlO2.png",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
},
{
category: "jewellery",
subCategory: "earring",
status: "PUBLISHED",
productName: "Test earring",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
meta: {
size: "",
},
},
];
GlamAr.applyMultipleConfigData(data);

Users will see separate tabs for each category type in the SDK UI.

on​

GlamAr.on(eventName, handlerFunction);

Adds the listener to the given event name. The returned value is used to un-register to event.
Return Value: EmitterSubscription

ParametersTypeDescription
eventNamestring

A Name of specific event or "*" To listen to the all the events.

handlerFunctionfunction Your handler function that will listen to callback.

Following is an example to properly handle event listening

useEffect(() => {
GlamAr.init({
accessKey: "YOUR_ACCESS_KEY",
});

const sub1 = GlamAr.on("photo-loaded", (data) => console.log(data));
const sub2 = GlamAr.on("loaded", () => console.log("Loaded"));

return () => {
sub1?.remove?.();
sub2?.remove?.();
};
}, []);

reset​

Removes all applied effects when called without arguments. In multi-try-on, pass a subcategory string or an options object/map to remove selected effects while keeping the others.

GlamAr.reset();
GlamAr.reset("blush");
GlamAr.reset({ subCategory: "blush" });
GlamAr.reset({ skuIds: ["sku-1", "sku-2"] });
ParameterTypeDescription
valuestring or ResetOptionsOptional. A subcategory string is shorthand for the subCategory option.
subCategorystringSubcategory to clear, such as blush.
skuIdsstring[]IDs of applied SKUs to remove. Pass individual IDs as list entries.

If both filters are supplied, a nonempty skuIds list takes precedence over subCategory. Omitting the argument, passing an empty string, or passing options with no nonempty filter clears all effects.

Returns no value.

configChange​

Updates an adjustment for the active try-on. Availability depends on the current product and experience. skuId and subCategory select the makeup opacity target during multi-try-on; they do not scope finger, position, or scale adjustments.

Use configChange(type, value?, skuId?, subCategory?). The native API takes positional arguments, not the Web wrapper’s object form. Use undefined or null to skip an optional argument.

GlamAr.configChange("opacity", 0.5);
GlamAr.configChange("fingers", 2);
GlamAr.configChange("horizontal", 0);
GlamAr.configChange("vertical", 0);

// Target makeup opacity during multi-try-on.
GlamAr.configChange("opacity", 0.5, "sku-1");
GlamAr.configChange("opacity", 0.5, undefined, "lipstick");

// Select the makeup opacity target without changing its value.
GlamAr.configChange("opacity", undefined, undefined, "lipstick");
ParameterTypeDescription
typestringRequired. opacity (also accepted as intensity), fingers, horizontal, vertical, or scale.
valuenumberNumeric adjustment. Supply a value when changing an adjustment. For opacity/intensity, omitting the value selects the target without changing its opacity.
skuIdstringOptional applied makeup SKU ID to target.
subCategorystringOptional applied makeup subcategory to target, such as lipstick or blush.

Pass one target selector per call. With neither selector, the SDK uses its active makeup target. Returns no value.

setViewportMirrored​

GlamAr.setViewportMirrored(state);

Enables or disables mirrored viewport rendering for AR Try-On.
Return Value: None

GlamAr.setViewportMirrored(true); // Enable mirrored viewport
GlamAr.setViewportMirrored(false); // Disable mirrored viewport
ParametersTypeDescriptionOptions
statebooleanControls whether the AR viewport should render in mirrored mode.

true: enable mirror mode
false: disable mirror mode

close​

GlamAr.close();

Closes canvas and returns to the main widget page.
Return Value: None

ParametersDescription

None

No parameters required.

snapshot​

GlamAr.snapshot();

Takes a snapshot of the current result window. Result of the screen can be get from photo-loaded event in base64 formate.
Return Value: none

ParametersDescription

None

No parameters required.

comparison​

GlamAr.comparison(state, skus);

Toggles comparison mode in AR widget.
Return Value: None

Pass a state (i.e, open or close) to toggle between UI and with it 2 SKU ids or Skuconfig of same subcategory say sunglasses or necklace. Diffrent subcategory comparision is not supoorted. The first sku will be shown on the left side and the other one on the right side.

ParametersTypeDescriptionOptions
statestringState to show or hide the UI respectivelyopen close
skusstring[] | object[]Provide 2 SKU Ids or 2 SKU json in an array

["skudID1", "skudID2"]
["SkuConfig1", "SkuConfig2"]

GlamAr.comparison("open", ["skudID1", "skudID2"]); // replace skudID1 and skudID2 with two SKU id's
GlamAr.comparison("close"); // When we send close we don't need to send SKUs

setExperience​

Switches between AR Try-On and Skin Analysis in the initialized SDK without reloading the full SDK. Wait for the loaded event before calling it.

import { GlamAr } from "@glamario/core-react-native";

GlamAr.setExperience("vto", { category: "eyewear" });
GlamAr.setExperience("vto", { subCategory: "lipstick" });
GlamAr.setExperience("vto", { skuId: "sku-1" });
GlamAr.setExperience("skinAnalysis", { appId: "your-app-id" });
ParameterDescription
experienceRequired. Exactly vto or skinAnalysis (case-sensitive).
optionsRequired. VtoExperienceOptions for vto, or SkinAnalysisExperienceOptions for skinAnalysis.
category, subCategory, skuIdVTO selectors. Provide one nonblank string in the options. skuId is the exact merchant SKU from variants[].skuId, not a product ID or variant UUID.
appIdRequired nonblank Skin Analysis app ID in the options.

Selector values are trimmed. If multiple VTO selectors are supplied, the first nonblank value wins in this order: category, subCategory, skuId. Invalid experience/options emit experience-change-failed without switching.

This method returns no value. Listen for experience-changing, experience-changed, and experience-change-failed to track completion or failure.

open​

Use open and its mode variants only when you disable or override the SDK's built-in hero screen and implement your own screen or launch buttons. The built-in hero screen already provides buttons to open the SDK, so no open call is needed when using it. After applying a SKU, call the appropriate variant from your custom button handler.

GlamAr.open();

Opens the AR widget.
Return Value: None

ParametersTypeDescriptionOptions
modestringOpens Live-Tryon, Model/Image-tryon and Model ViewermodelViewer imgTryOn
imgURLstringValid image URLAny valid URL
  • No parameters: Start Live VTO

    GlamAr.open();
  • Model Viewer: Start Model Viewer

    GlamAr.open("modelViewer");
  • Image Try-On:

    • Opens the image/model selection screen:
      GlamAr.open("imgTryOn");
    • Opens try-on directly with a specific image:
      GlamAr.open("imgTryOn", "url_of_image");

Switching Views​

  • While in Live or Image mode, calling:

    GlamAr.open("modelViewer");

    will open the model viewer. Calling GlamAr.open() again returns to the selected Try-On type.

  • To switch from Live to Image mode, call:

    GlamAr.back();

    This resets the Try-On session and then call GlamAr.open() with desired parameter

Note: The SKU must already be applied. If not, the SDK will display an error.

Eye PD Measurement Flow​

We provide an integrated supports for eye pupillary distance (PD) scanning. This is activated when viewing any eyeware categories. If user wants to show his own UI and use this service we have function GlamAr.eyePD() for that case.

GlamAr.eyePD("start"); // To launch or restart Eye PD flow
GlamAr.eyePD("close"); // To exit Eye PD and return to active Try-On

Events​

The sku-applied event includes the applied SKU configuration in data. See the platform-specific callback examples there to read the correct payload shape.

Refer to Setup Page to understand how we can register to events listed Check Events Page for event details.