Zzap
Zzap

Reputation: 174

Safari Notification.permission state can't be reset

I'm testing safari 16+ versions' push api capabilities using a service worker. After i clicked allow on the push notification dialog, Notification.permission goes granted. Then for testing purposes i reset the notification permissions from settings->websites->notifications and remove the website i opted-in. Now this notifications list is empty but when i go to that site and check Notification.permission it still prompts "granted".

I was expecting to find a way to reset the permission state so that i can follow same steps from scratch. But i'm not able to make permission state to "default" once it is set. At first i was able to see the website in notifications list but after some time and couple of trials it shows nothing.

I tried to flush all the safari's cache, updating the version and restart the browser. But i couldn't find a way to reset this setting to be able to do tests from scratch. The list under settings->websites->notifications is still empty.

Tried safari Version 16.0 16.1 and 16.2 they all acted the same.

Upvotes: 1

Views: 1188

Answers (1)

BERKAN SEZER
BERKAN SEZER

Reputation: 26

i've just found a workaround solution for this issue.

Your Notification Permissions are storing ~/Library/Safari/RemoteNotifications/Permissions.plist file. You can not change it on your terminal but you can follow this steps:

  • Be sure Safari already closed.
  • Firstly copy this XML and create a file with same name (Permissions.plist) on somewhere.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
  • Go to Safari Folder via: $ cd ~/Library/Safari
  • Open this folder on Finder: $ open .
  • Scroll down and find RemoteNotifications folder and open it
  • Change Permissions.plist file's name as old_Permissions.plist (maybe you need it later)
  • Drag your new clean Permissions.plist file here
  • Congrats. You can open Safari now and old Notification permissions will be reseted.

Upvotes: 1

Related Questions