Chuyển tới nội dung chính

openDeeplink

openDeeplink là JS API dùng để mở một URL từ AI App. Framework tự động chuyển tiếp tới host API tương ứng (V-App, ChatGPT, ...).

Import

import apis from '@v-miniapp/ai/apis'

Tham số

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
urlstringURL cần mở
success(res: boolean) => voidCallback khi thành công
fail(error) => voidCallback khi thất bại
complete() => voidCallback khi hoàn tất (dù thành công hay thất bại)

Giá trị trả về

  • boolean: true nếu mở thành công, false nếu thất bại.

Ví dụ

Callback

import apis from '@v-miniapp/ai/apis'

apis.openDeeplink({
url: 'https://vingroup.net',
success: (res) => {
console.log('Mở thành công', res)
},
fail: (err) => {
console.error('Lỗi', err)
},
})

Async/Await

import { apisAsync } from '@v-miniapp/ai/apis'

try {
const res = await apisAsync.openDeeplinkAsync({
url: 'https://vingroup.net',
})
console.log('Mở thành công', res)
} catch (err) {
console.error('Lỗi', err)
}