openWebview
Bắt đầu hỗ trợ ở phiên bản:
- SDK: 2.11.0
Lưu ý
Cần xin cấp quyền tại trang Quản lý ứng dụng
Mở Webview. Lắng nghe sự kiện WebviewClosed ở app cần biết khi nào webview được đóng.
Parameters
Object object
| Property | Type | Default | Required | Description | Minimum Version |
|---|---|---|---|---|---|
| url | string | yes | |||
| config | object | Cấu hình cho webview | 2.30.0 | ||
| success | function | Callback function khi gọi api thành công | |||
| fail | function | Callback function khi gọi api thất bại |
Object config
| Property | Type | Default | Required | Description | Minimum Version |
|---|---|---|---|---|---|
| style | string | bottomSheet | Kiểu hiển thị cho webview:
| ||
| leftButton | string | back | Nút bên trái thanh header: (chỉ hỗ trợ cho style 'bottomSheet')
|
Sample Code
import { openWebview } from "zmp-sdk/apis";
openWebview({
url: "https://mini.zalo.me/",
config: {
style: "bottomSheet",
leftButton: "back"
},
success: (res) => {
// xử lý khi gọi api thành công
},
fail: (error) => {
// xử l ý khi gọi api thất bại
console.log(error);
}
});
Hoặc
import { openWebview } from "zmp-sdk/apis";
const openUrlInWebview = async () => {
try {
await openWebview({
url: "https://mini.zalo.me/",
config: {
style: "bottomSheet",
leftButton: "back"
}
});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};