How to reset push notification permission on macOS

⋅ 2 min read ⋅ macOS

Table of Contents

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Problem: Notification permission not reset

When you request permission to use push notifications for the first time on a Mac, the system will present the following dialog asking users to grant the permission.

Notification permission dialog.
Notification permission dialog.

Once users choose to allow or deny the permission, their choice will be remembered. They can change their mind in the "System Preferences > Notifications & Focus" menu.

Notifications & Focus.
Notifications & Focus.

During the development, you might want to reset notification permission back to the clean state (UNAuthorizationStatus.notDetermined) to test out every possible scenario for your app.

If you try to remove the app by deleting it from DerivedData and rerun your app, you will find an unpleasant truth. The user choice is still remembered!

Turn out reset push notification permission on macOS isn't as straightforward as how we do it on iOS.

How to reset push notification permission on macOS

I have good and bad news here.

The good news is I have a reliable way to reset notification permission to where it was. The bad news is it is not elegant and involve restarting your mac :(

To reset a push notification permission in macOS. First, you have to delete your app. To do that:

  1. Make sure you app doesn't running in Xcode. If it does, just stop it by select Product > Stop or ⌘ - command + ..
  2. Then, remove the app from DerivedData. You can locate the DerivedData by opening Xcode preferences from the Xcode menu. Go to the "Locations" tab. You will find a path to your DerivedData. You can also click the little arrow to jump right to it.

  3. You will find a lot of things in that folder. You should find one with a random suffix. Here is mine reset-notification-permission-cxubvioxnwciooapteewxblofwin. Once you find your app, delete it.
  4. Then restart your Mac.

And that's all you need to do to reset a push notification permission on macOS.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Conclusion

I wish I know a better way to do this, but this is the only way I know right now. If you happen to know a better way, please let me know. You can contact me via Twitter. My DM is always open.


Read more article about macOS or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.

Become a patron Buy me a coffee Tweet Share
Previous
How to remove a DEBUG banner in Flutter App

When you run a Flutter app for the first time, you probably notice a debug banner in the upper right of the screen. Learn what it is and how to remove it.

Next
What is the iOS version global market share

Find out where we can get information about the iOS version market share.

← Home