Yesterday, I was working on Transloader v3.0. In particular, on its push notifications and making sure everything syncs properly.
Today, I wanted to continue working on this, but found myself unable to. My Mac suddenly didn’t receive CloudKit push notifications anymore.
Even worse, neither of the delegate methods
- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
and
- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
weren’t called anymore – without any code changes. Something was wrong.
But here we are, a couple of hours later, and everything’s working again. Finally.
So, to save you some time should this happen to you, here’s what I did:
Restart
I restarted my Mac – the obvious solution. You might think. Only that it didn’t work, the problem persisted. But it’s still the first thing I’ll try if this returns.
Delete Containers, Group Containers, and CloudKit Caches
In Finder, delete
/Users/yourname/Library/Containers/yourAppContainerFolder/
/Users/yourname/Library/Group Containers/yourGroupID.yourAppGroupContainerFolder/
/Users/yourname/Library/Caches/CloudKit/yourAppID
/Users/yourname/Library/Caches/CloudKit/CloudKitMetadata* (*all files that begin with that filename)
/Users/yourname/Library/Caches/CloudKit/CloudKitOperationInfo* (*all files that begin with that filename)
Now launch Activity Monitor.app and force quit the following processes:
cfprefsd
apsd
notifyd
remoted
Now, I’m not sure you need to force-quit each and every one of those, but I wanted to relaunch any process that remotely looked like it had to do with remote/push notifications.
At this point, I restarted Transloader through Xcode, and lo and behold, it worked again.
On my MacBook Pro, where the same problem occurred simultaneously, I took the same steps. And it *didn’t* work. A restart was required, so your mileage – like mine – may vary.
Additional Info
There’s also this handy technical note from Apple, which can help debugging push notifications on both macOS and iOS.