Album
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 ·
FetchAlbumItemsOptionsIt 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
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 ·
10The maximum number of items to import.
maxWidthnumber ·
1024The maximum width of the image. The unit is pixels.
base64boolean ·
falseWhether to return the image's
dataUrias a Base64 string.
AlbumItemResponse
Properties:
idstring
This is the item's unique ID.
data ·
UristringMedia data URI.
typeIf it isPHOTOandbase64optiontrueis set, it is returned as a Base64 string.type'PHOTO' | 'VIDEO'
This is the media type.
2. Fetch album
SDK function: fetchAlbumPhotos
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 ·
numberThe maximum number of photos to import.
options.maxWidth ·
numberThe maximum width of the photo. The unit is pixels.
options.base64 ·
booleanSet 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?