react-native-younify-connect-sdk
    Preparing search index...

    Interface IConnect

    Younify Connect SDK main interface.

    Caution: When invoking a method, the sdk uses a limited task based processing architecture that may delay the execution of new operations until previous ones complete. Special care should be taken when performing sdk operations in the background while allowing the user to interact in the foreground. Long running background operations could negatively impact the responsiveness of your app. If you choose to use background operations, consider making them as short as possible or cancel them when users interact in the foreground.

    interface IConnect {
        configure(options: ConnectOptions): Promise<void>;
        clearUserData(): Promise<void>;
        setUserTokens(
            accessToken: string | null,
            refreshToken: string | null,
        ): Promise<void>;
        requiresUserConsent(
            cancellationTicket: CancellationTicket | null,
        ): Promise<boolean>;
        requestUserConsent(
            cancellationTicket: CancellationTicket | null,
        ): Promise<boolean>;
        linkService(
            service: StreamingService,
            cancellationTicket: CancellationTicket | null,
        ): Promise<boolean>;
        manageLinkedService(
            service: StreamingService,
            cancellationTicket: CancellationTicket | null,
        ): Promise<void>;
        unlinkService(
            service: StreamingService,
            cancellationTicket: CancellationTicket | null,
        ): Promise<void>;
        fetchServices(
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingService[]>;
        fetchLinkedServices(
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingService[]>;
        fetchBrokenServices(
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingService[]>;
        fetchCategories(
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingCategory[]>;
        fetchContent(
            categories: StreamingCategory[],
            services: StreamingService[],
            cancellationTicket: CancellationTicket | null,
            serviceError: ((service: StreamingService, error: Error) => void) | null,
            categoryServiceComplete:
                | (
                    (
                        category: StreamingCategory,
                        service: StreamingService,
                        content: StreamingContent[],
                        error: Error | null,
                    ) => void
                )
                | null,
        ): Promise<FetchContentCategoryResult[]>;
        fetchContentChildren(
            content: StreamingContent,
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingContent[]>;
        fetchContentDetails(
            content: StreamingContent,
            cancellationTicket: CancellationTicket | null,
        ): Promise<StreamingContentDetails>;
        searchContent(
            services: StreamingService[],
            searchPhrase: string,
            cancellationTicket: CancellationTicket | null,
            serviceComplete:
                | (
                    (
                        service: StreamingService,
                        content: StreamingContent[],
                        error: Error | null,
                    ) => void
                )
                | null,
        ): Promise<SearchContentServiceResult[]>;
        fetchImage(
            url: string,
            cancellationTicket: CancellationTicket | null,
        ): Promise<string>;
    }

    Implemented by

    Index

    Methods

    • Configures the SDK with the specified options.

      Parameters

      • options: ConnectOptions

        The configuration options.

        Before using the sdk it must be configured by using this method with a valid ConnectOptions instance. It is safe to call this method repeatedly to change the options dynamically at runtime if desired.

      Returns Promise<void>

    • Clears all user data.

      User data locally persisted on device or retained in memory will be cleared, including user tokens.

      Returns Promise<void>

    • Sets the user's tokens.

      Parameters

      • accessToken: string | null

        The user's access token.

      • refreshToken: string | null

        The user's refresh token.

        Set the user's access and refresh tokens that are required for accessing streaming services. User tokens can be obtained by creating a user object from the backend api.

      Returns Promise<void>

    • Determines if the user has required pending consent actions.

      Parameters

      • cancellationTicket: CancellationTicket | null

        The ticket to manually cancel the operation.

      Returns Promise<boolean>

      A boolean indicating whether there are pending consents or not.

    • Requests the user to consent to the privacy policy if it has not yet been accepted.

      Parameters

      • cancellationTicket: CancellationTicket | null

        The ticket to manually cancel the operation.

      Returns Promise<boolean>

      A boolean indicating whether the user consented to all mandatory documents or false if they did not.

      Opens the legal document consent flow if consents are pending or returns immediately with true if all consents are satisfied.

    • Link a streaming service.

      Parameters

      Returns Promise<boolean>

      A boolean indicating whether the service was linked or not.

      Opens the service linking flow which involves a web view login for the specified service followed by profile selection and optional pin collection if supported. If linking is successful, the success flag will be true. If linking was canceled then the success flag will be false. If linking fails the promise will reject.

      Caution: Given the task based architecture of the sdk and the asynchronous nature of this method, care should be taken when invoking it from user interactive elements to debounce or otherwise prevent multiple invocations until the previous one completes.

    • Manage a linked service.

      Parameters

      Returns Promise<void>

      The service object that was managed.

      Opens the linked service management flow which allows the user to change their profile selection and pin if supported.

      Caution: Given the task based architecture of the sdk and the asynchronous nature of this method, care should be taken when invoking it from user interactive elements to debounce or otherwise prevent multiple invocations until the previous one completes.

    • Unlink a linked service.

      Parameters

      Returns Promise<void>

      The service object that was unlinked.

    • Fetch streaming category contents.

      Parameters

      • categories: StreamingCategory[]

        The list of categories to fetch content for.

      • services: StreamingService[]

        The list of streaming services to fetch content for.

      • cancellationTicket: CancellationTicket | null

        The ticket to manually cancel the operation.

      • serviceError: ((service: StreamingService, error: Error) => void) | null

        The optional error handler to call when a problem occurs accessing a service.

      • categoryServiceComplete:
            | (
                (
                    category: StreamingCategory,
                    service: StreamingService,
                    content: StreamingContent[],
                    error: Error | null,
                ) => void
            )
            | null

        The optional completion handler to call when retrieving content for a single category and service.

      Returns Promise<FetchContentCategoryResult[]>

      Complete fetched content for all services and all categories or an empty array if categoryServiceComplete is non-null.

      Retrieves the content for the categories and services specified. serviceError will be called when a service error occurs. categoryServiceComplete will be called with the results for a single category-service pair. Specifying this callback will cause the response promise to resolve with an empty array for performance.

    • Fetch content children.

      Parameters

      Returns Promise<StreamingContent[]>

      The children of the requested content item.

      Retrieves the children of the given parent content object. The content object must be a folder to have children.

      Examples include using a content that represents a series where the children would be its seasons, or a content that represents a season where the children would be its episodes.

    • Search a streaming service.

      Parameters

      • services: StreamingService[]

        The streaming service to search.

      • searchPhrase: string

        The list of streaming services to fetch content for.

      • cancellationTicket: CancellationTicket | null

        The ticket to manually cancel the operation.

      • serviceComplete:
            | (
                (
                    service: StreamingService,
                    content: StreamingContent[],
                    error: Error | null,
                ) => void
            )
            | null

        The optional completion handler to call when retrieving search results for a single service.

      Returns Promise<SearchContentServiceResult[]>

      Complete search results for all services or an empty array if serviceComplete is non-null.

      Searches the given services with the specified searchPhrase. serviceComplete will be called with the results for a single service. Specifying this callback will cause the response promise to resolve with an empty array for performance.

    • Fetch an image.

      Parameters

      • url: string

        The image url to fetch.

      • cancellationTicket: CancellationTicket | null

        The ticket to manually cancel the operation.

      Returns Promise<string>

      Image data as a base64 string.

      Retrieves the image from the specified image url.

      Directly fetching image urls in any other way can lead to missing data or 404s depending on the streaming service.