This is the default implementation of a sharing provider. In most cases there is no need to customize this, but to just use the defaultSharingProvider.

To handle sharing links correctly, the application should call the SharingProvider.getShareState of the defaultSharingProvider and if an IShareState object is provided, the host application should call the IVirtualStylingApi.show method providing the share state.

     const vsc = ...; /// Get an IVirtualStylingBuilder instance
const informationProvider = ...; /// Get an IGarmentInformationProvider instance
const organizationId = "....";
const sharedState = await defaultSharingProvider.getShareState(window.location.href);
if (sharedState) {
if (sharedState.type === "pictofit::virtualstyling::outfit" || sharedState.type === "pictofit::virtualstyling::style") {
const referenceId = typeof sharedState.collection === "string" ? sharedState.collection : sharedState.collection.reference;
const organizationId = typeof sharedState.collection === "string" ? undefined : (sharedState.collection.organizationId ?? organizationId);
try {
const result = await vsc.getCollection(referenceId, organizationId);
if (result === null) {
throw new Error(`Failed to open shared link, collection not found!`);
}
(await vsc.build()).api.show(Promise.resolve(result), sharedState.collection, {
commerceProvider,
informationProvider: Promise.resolve(informationProvider),
sharedState
});
} catch (e) {
console.error(`Failed to open shared link, collection not found!`, e);
}
}
}

Implements

Constructors

Methods