1. 개발자를 위한 웹 기술
  2. Web API
  3. PushSubscription
  4. toJSON()

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

PushSubscription: toJSON() 메서드

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023년 3월.

보안 컨텍스트: 이 기능은 일부 또는 모든 지원 브라우저보안 컨텍스트 (HTTPS)에서만 사용할 수 있습니다.

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

PushSubscription 인터페이스의 toJSON() 메서드는 표준 직렬 변환기입니다. 구독 속성의 JSON 표현을 반환하여 유용한 단축 방법을 제공합니다.

구문

js
toJSON()

매개변수

없음.

반환 값

JSON 객체. 이 객체는 구독 엔드포인트, expirationTime 그리고 공개 키를 포함하며, 각각은 endpoint 멤버, expirationTime 멤버, keys 멤버입니다.

예제

js
navigator.serviceWorker.ready.then((reg) => {
 reg.pushManager.getSubscription().then((subscription) => {
 const mySubscription = subscription.toJSON();
 // 구독 세부 정보로 무언가 하기
 });
});

명세서

Specification
Push API
# dom-pushsubscription-tojson

브라우저 호환성

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /