PushSubscription: unsubscribe() 메서드

Baseline 2023
Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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

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

PushSubscription 인터페이스의 unsubscribe() 메서드는 현재 구독이 성공적으로 구독 취소될 때 불리언 값으로 이행되는 Promise를 반환합니다.

구문

js
unsubscribe()

매개변수

없음.

반환 값

현재 구독이 성공적으로 구독 취소될 때 불리언 값으로 이행되는 Promise.

예제

js
navigator.serviceWorker.ready.then((reg) => {
  reg.pushManager.getSubscription().then((subscription) => {
    subscription
      .unsubscribe()
      .then((successful) => {
        // 성공적으로 구독을 취소했습니다
      })
      .catch((e) => {
        // 구독 취소에 실패했습니다
      });
  });
});

명세서

Specification
Push API
# dom-pushsubscription-unsubscribe

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
unsubscribe()

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

같이 보기