Registering for remote notifications appears broken in Big Sur

November 07, 2020

Updated Nov 8: I did further testing and realized that registering for remote notifications works in production environment on Big Sur, but not in development environment. The original version of this post stated that it doesn’t work at all on Big Sur, which would be a big deal. Not working in development environment is obviously annoying to developers, but has no real user impact. I’ve edited this post to reflect this learning.

TL;DR: registering for remote notifications in development environment appears to be broken in Big Sur. This code works for me as expected in Catalina with both development and production configurations. On Big Sur, it works in production context, but not during development. I’ve been looking for an explanation and solution for a while, but no luck so far.

macOS Big Sur is about to be released publicly soon. All macOS users will get a major design update with this release. Us developers have been looking at it for a while already, and I quite like working with it. There’s one area where I am having trouble with though, and haven’t found a solution so far. Hence, I’m writing this up publicly, in the hope that someone can point towards what I am doing wrong.

Remote notifications are generally a pretty stable part of the Apple SDK. It first shipped on iOS many versions ago, and was later added to macOS. To my knowledge, there weren’t any API and SDK changes in Big Sur in this area. The code I had working in Catalina should just remain working in Big Sur.

Alas, that is not the case for me. I have made a small example app that you can just build and run. It first asks the user for authorization to send notifications. If the user grants it, the app then registers to receive remote notifications. It obtains a device token that I can later use to send notifications to the device.

Everything works as expected in Catalina. You see these lines in the log.

2020-11-07 14:19:41.581802+0200 BigSurRemoteNotifications[59054:1699865] [App delegate] Notification authorization ok, registering for remote notifications
2020-11-07 14:19:44.930732+0200 BigSurRemoteNotifications[59054:1699373] [App delegate] Did register for remote notifications. Token length: 32

On Big Sur, it’s a different story. Neither the didRegisterForRemoteNotificationsWithDeviceToken nor didFailToRegisterForRemoteNotificationsWithError callbacks are called. One of them should always be called. Here’s what I see in the log on Big Sur when running in development context, such as building and running straight from Xcode.

2020-11-07 10:58:47.851135+0200 BigSurRemoteNotifications[2823:36378] [App delegate] Notification authorization ok, registering for remote notifications

The registration just appears to hang forever.

I have never seen this work in Big Sur in development environment. It has been broken like this since the first beta. I’ve checked with each subsequent beta release for any behavior changes, but nothing so far. And now we have Big Sur Release Candidate out where this is similarly not working.

This thread in Apple developer forum suggests that it might be due to my network setup. Someone from Apple claims that they had connectivity problems in APNs developer environment at some point. Fair enough. This is also why I use os_log for logging: I can build the app with production configuration and then see the logs in system console.

When I build the app on Big Sur and then export a notarized and signed copy of it which is built against production APNS environment, it appears to be working as expected. I stream the app log and can see the callback being called.

Notification registration callback on Big Sur

To sum it up, it works on Catalina with both development and production configurations, and on Big Sur only with production configuration. I am using exactly the same iMac and network environment with the same code, suggesting to me that it really is something about the operating system.

So that’s where I am. Usually in a situation like this, when something is not working as expected, one of these two is true. (Sometimes both. But usually one.)

  1. I am doing something wrong.
  2. There is something wrong with the underlying system and platform.

I would happily fix my mistake if I knew what I was doing wrong. I just fail to see what it is, or what and where to look for. The notification registration API and system behavior hasn’t changed. There aren’t any warnings or deprecations in Xcode. The network is fine. It really is just working in Catalina and not working in Big Sur.

I have filed FB8731513 to Apple about this a while ago. It doesn’t have any reactions from Apple, but status remains “Open”.

If you happen to be a developer on Big Sur, perhaps you could test this and see if you get similar results? Let me know on Twitter or such. I’ll update this post once I find out more.