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.