0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

許可しているかどうかを取得する

Last updated at Posted at 2023-09-30

Navigator.permissionsプロパティで、対象リクエストの許可が取れているかどうかを確認する。
返ってくる値はgranteddeniedpromptの3つある。
それぞれ、許可、不許可、確認が取れていない状態である。

navigator.permissions.query({ name: "geolocation" }).then(function (permissionStatus) {
    console.log(`パーミッションの状態は ${permissionStatus.state}  です`);
});

上記のコードは位置情報の許可が取れているかどうかを取得する。
位置情報の他に通知許可はnotifications、カメラの許可はcameraなどがある。

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?