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ính | Kiểu dữ liệu | Bắt buộc | Mô tả |
|---|---|---|---|
| url | string | ✅ | URL cần mở |
| success | (res: boolean) => void | Callback khi thành công | |
| fail | (error) => void | Callback khi thất bại | |
| complete | () => void | Callback khi hoàn tất (dù thành công hay thất bại) |
Giá trị trả về
boolean:truenếu mở thành công,falsenế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)
}