OptiView Ads SDK for React Native
    Preparing search index...

    Interface OptiViewAdsConnector

    The OptiView Ads connector for a single React Native player instance.

    The connector is a thin, typed facade over the native OptiViewAds orchestrator (ads-sdk on Android, OptiViewAdsSDK on iOS). All scheduling, cue matching, ad rendering, and IMA work happens natively — never on the JS thread, which may be paused (PiP, background). Events emitted while the JS thread is paused are buffered natively and delivered on resume.

    Methods mirror the web OptiViewAds class; asynchronous ones return promises because every call crosses the bridge.

    interface OptiViewAdsConnector {
        addEventListener<T extends OptiViewAdsEventType>(
            event: T,
            handler: OptiViewAdsEventHandler<T>,
        ): void;
        clickAd(): Promise<string | null>;
        destroy(): Promise<void>;
        endSession(): Promise<void>;
        exportDiagnostics(): Promise<DiagnosticReport>;
        getAdBreakStatus(): Promise<AdBreakStatus>;
        getMuted(): Promise<boolean>;
        getPresentationState(): Promise<RnPresentationState>;
        getVolume(): Promise<number>;
        notePictureInPicture(active: boolean): Promise<void>;
        offDiagnostic(handler: DiagnosticHandler): void;
        onDiagnostic(handler: DiagnosticHandler): void;
        removeEventListener<T extends OptiViewAdsEventType>(
            event: T,
            handler: OptiViewAdsEventHandler<T>,
        ): void;
        seek(time: number): Promise<void>;
        setManifestRequestInterceptor(
            interceptor: ManifestRequestInterceptor | null,
            policy?: InterceptorPolicy,
        ): void;
        setManifestResponseInterceptor(
            interceptor: ManifestResponseInterceptor | null,
            policy?: InterceptorPolicy,
        ): void;
        setMuted(muted: boolean): Promise<void>;
        setVolume(volume: number): Promise<void>;
        skipAd(): Promise<boolean>;
        startSession(config: SessionConfig): Promise<void>;
        updateAssetParameterMacros(
            macros: AssetParameterMacroUpdates,
        ): Promise<void>;
        updateAssetParameters(params: Record<string, string>): Promise<void>;
    }

    Implemented by

    Index
    • Detach from the player and destroy the native SDK instance. Idempotent. Must be called before the hosting player view unmounts.

      Returns Promise<void>

    • End the current session. Mirrors web OptiViewAds.endSession.

      Returns Promise<void>

    • Start an ad session for a channel. Mirrors web OptiViewAds.startSession.

      Parameters

      Returns Promise<void>

    • Replace the live-update layer of the asset parameters. Mirrors web OptiViewAds.updateAssetParameters.

      Per-key precedence: SessionConfig.assetParameters < updateAssetParameters() < the manifest session layer (vendorConfiguration.gam.sgai[0].assetParameters or ssai[0].assetParameters) < the per-asset assetParameters. It replaces the previous update rather than accumulating onto it. Applies to future ad breaks.

      Parameters

      • params: Record<string, string>

      Returns Promise<void>

    • Report an ad click and return its click-through URL without navigating.

      Returns Promise<string | null>

    • Snapshot of the current/upcoming ad break. Mirrors getAdBreakStatus.

      Returns Promise<AdBreakStatus>

    • Whether ad playback is muted. Mirrors web OptiViewAds.muted.

      Returns Promise<boolean>

    • What the SDK is presenting right now: whether the content player is in picture-in-picture, and which media owns the surface. Mirrors the web OptiViewAds.getPresentationState() — both halves are the SDK's own decisions, so an application (or test harness) inferring them would be duplicating rules that change. The one every PiP integration needs: while pinned, a forced-single ad plays THROUGH the content player (insertion: 'shared-element'), so the player's own clock reports the AD's progress — anything displaying or asserting content position must consult showing/insertion instead of reading the player directly.

      Returns Promise<RnPresentationState>

    • Ad playback volume in [0, 1]. Mirrors web OptiViewAds.volume.

      Returns Promise<number>

    • Report the host app's picture-in-picture state so the SDK can adjust the break layout (a PiP window is one small surface, so multi-surface break formats are forced to single while pinned).

      Only needed for host players whose library has no presentation-mode event surface the bridge can observe — i.e. react-native-video, where the integrator wires it from the view's own event:

      <Video onPictureInPictureStatusChanged={(e) => connector.notePictureInPicture(e.isActive)} 
      

      react-native-theoplayer hosts must NOT call this: the bridge already observes the player's presentation-mode events there, and the call is ignored natively (one source of truth per instance). State-only — the SDK never opens or closes a PiP window itself.

      Parameters

      • active: boolean

      Returns Promise<void>

    • Seek content to time seconds. Mirrors web OptiViewAds.seek: the SDK owns the seek policy — suppressed during breaks with controls.snapback, no-op without a session. Prefer this over seeking the host player directly, which bypasses the policy.

      Parameters

      • time: number

      Returns Promise<void>

    • Mute or unmute ad playback; content follows the SDK's audio rules.

      Parameters

      • muted: boolean

      Returns Promise<void>

    • Set the ad playback volume in [0, 1]; values outside are clamped.

      Parameters

      • volume: number

      Returns Promise<void>

    • Skip the active ad break when its manifest policy allows it.

      Returns Promise<boolean>