For the complete documentation index, see llms.txt. This page is also available as Markdown.

Album

Permission settings are required

fetchAlbumItemsYou need to set album permissions before using it. Please check the permission setup guide first.


1. Select album media

SDK function: fetchAlbumItems

A function that selects and imports photos and videos from the user's album. You can select photos and videos at the same time, and if the user cancels the selection, an empty array []returns null.

Signature

function fetchAlbumItems(options?: FetchAlbumItemsOptions): Promise<AlbumItemResponse[]>;

Parameters

  • options · FetchAlbumItemsOptions

    It is an object containing the query options. See below for the detailed type FetchAlbumItemsOptionsPlease refer to it.

Return value

  • Promise<AlbumItemResponse\[]>

    Returns the selected media list. If the user cancels, it returns an empty array.

Error

Error code
Trigger condition

NOT_ALLOWED

When album access is not allowed

INVALID_REQUEST

When the request parameters are invalid

INVALID_DATA

When the media data is invalid

UNSUPPORTED_APP_VERSION

When the Toss app version is lower than 5.261.0

Example

FetchAlbumItemsOptions

Properties:

  • typesArray<'PHOTO' | 'VIDEO'>

    A list of media types to import. 'PHOTO'(photo), 'VIDEO'You can choose from (video). If not specified, only photos are imported.

  • maxCountnumber · 10

    The maximum number of items to import.

  • maxWidthnumber · 1024

    The maximum width of the image. The unit is pixels.

  • base64boolean · false

    Whether to return the image's dataUrias a Base64 string.

AlbumItemResponse

Properties:

  • idstring

    This is the item's unique ID.

  • data · Uristring

    Media data URI. typeIf it is PHOTOand base64 option trueis set, it is returned as a Base64 string.

  • type'PHOTO' | 'VIDEO'

    This is the media type.


2. Fetch album

SDK function: fetchAlbumPhotos

A new version is available

fetchAlbumPhotosOnly photos are supported. If you need to select photos and videos together or need finer control, fetchAlbumItemsplease use it.

A function that loads the photo list from the user's album. You can set the maximum number and resolution.

Signature

Parameters

  • options · Required

    It is an object containing the query options.

    • options.maxCount · number

      The maximum number of photos to import.

    • options.maxWidth · number

      The maximum width of the photo. The unit is pixels.

    • options.base64 · boolean

      Set whether to return the image in Base64 format.

Return value

  • Promise<ImageResponse\[]>

    Returns an array containing the album photo's unique ID and data URI.

Example

Last updated

Was this helpful?