PushMessageData: phương thức text()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is only available in Service Workers.
Phương thức text() của giao diện PushMessageData trích xuất dữ liệu push message dưới dạng một chuỗi văn bản thuần.
Cú pháp
js
text()
Tham số
Không có.
Giá trị trả về
Một chuỗi.
Ví dụ
js
self.addEventListener("push", (event) => {
const textObj = event.data.text();
// làm gì đó với văn bản của bạn
});
Thông số kỹ thuật
| Specification |
|---|
| Push API> # dom-pushmessagedata-text> |