Constructors

Properties

Accessors

Methods

Constructors

  • Create new instance of Push2Web object, it can be used to start listening for the events, subscribe or unsubscribe for notifications from Lens Studio. Also provides the extension object for the @snap/camera-kit package.

    Returns Push2Web

Properties

events: TypedEventTarget<Push2WebEvents> = ...

Use this property to subscribe for the different types of events that can occur during push 2 web execution.

Subscribe to error event to be aware if something has happened during the lens push, with network communication or any other type of error, event object also contains detailed explanation of the cause.

Use subscriptionChanged event to be aware when subscription state is changed.

Use lensReceived event to be aware when new lens is received from Lens Studio, also you can get the additional details about the pushed lens.

push2web.events.addEventListener('error', ({ detail }) => {
if (detail.name === 'LensExcludedError') {
console.log(`Lens is excluded from the push, by the following reason: ${detail.reason}.`)
}
})

Accessors

  • get extension(): ExtensionContainer
  • The extension object must be passed to the Camera Kit object during its bootstrap process. This is a requirement for the proper functioning of push to web functionality.

    Returns ExtensionContainer

    import { bootstrapCameraKit } from "@snap/camera-kit";

    const push2web = new Push2Web();
    const extensions = (container) => container.provides(push2Web.extension);

    const cameraKit = await bootstrapCameraKit({ apiToken: "token from developer portal" }, extensions);
    const cameraKitSession = await cameraKit.createSession();

Methods

  • Initiate subscription for the events from Lens Studio.

    Parameters

    • accessToken: string

      After user will be logged in to the web page, using Snapchat account, you can get access token from Login Kit.

    • cameraKitSession: CameraKitSession

      Instance of CameraKitSession object form @snap/camera-kit package.

    • repository: LensRepository

      Instance of LensRepository object from @snap/camera-kit package.

    Returns SubscriptionInstance