Not receiving CloudKit push notifications for Custom Record Zone on the Mac

江枫思渺然 提交于 2019-12-20 23:29:54

问题


I've setup a custom zone subscription to receive (silent) push notifications from my custom record zone. Everything works fine on my iOS devices but I'm not able to receive the notifications on my Mac.

To register the notifications I'm registering the notification type in applicationDidFinishLaunching:

[[NSApplication sharedApplication] registerForRemoteNotificationTypes:NSRemoteNotificationTypeNone];

(Tried the other types with the same result)

application:didRegisterForRemoteNotificationsWithDeviceToken:

is then called with a valid token. Everything seems fine but when the custom zone registers changes, I receive no notification and

application:didReceiveRemoteNotification:

is not called. I've also tried to set the alert body to an empty string like this:

CKNotificationInfo *info = [[CKNotificationInfo alloc] init];
info.alertBody = @"";
info.shouldSendContentAvailable = YES;

but it didn't work either. When I set a string as the alert body (and register the appropriate notification type) I also get a notification with that body in the top right corner but application:didReceiveRemoteNotification: is not called.

Hope you can help me. Thanks!


回答1:


Simply extracting the correct solution from one of the shared links: If you use a CKNotificationInfo for your alerts, didReceiveRemoteNotification will NOT be called on the Mac until and unless you set CKNotificationInfo.soundName to an empty string! This looks like a bug only in OS X (10.10 & 10.11 so far) but can be worked around by this simple change.




回答2:


I think it's fixed with macOS Sierra. Working for me now.

Edit: Oh wow: just noticed that I (!) asked this question 1,5y ago. :)



来源:https://stackoverflow.com/questions/28896830/not-receiving-cloudkit-push-notifications-for-custom-record-zone-on-the-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!