注册通知会导致mac出错

时间:2014-06-14 19:51:41

标签: objective-c xcode cocoa push-notification provisioning-profile

我正在做这样的事情:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application

    NSApplication *application = [aNotification object];
    NSRemoteNotificationType myTypes = NSRemoteNotificationTypeBadge;
    [application registerForRemoteNotificationTypes:myTypes];
}

//Successful
-(void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    NSLog(@"device token: %@", deviceToken);
}
//Failure to register
-(void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    NSLog(@"ERROR: %@\nError object: %@", [error localizedDescription], error);
}

我收到以下错误:

2014-06-14 20:47:13.656 RajamManagerStation[1878:303] ERROR: The operation couldn’t be completed. (OSStatus error 1.)
Error object: Error Domain=NSOSStatusErrorDomain Code=1 "The operation couldn’t be completed. (OSStatus error 1.)" (kCFHostErrorHostNotFound / kCFStreamErrorSOCKSSubDomainVersionCode / kCFStreamErrorSOCKS5BadResponseAddr / kCFStreamErrorDomainPOSIX / evtNotEnb / siInitSDTblErr / kUSBPending / dsBusError / kStatusIsError / kOTSerialSwOverRunErr / cdevResErr / EPERM:  / Error code is the version of SOCKS which the server wishes to use /  / POSIX errno; interpret using <sys/errno.h>  / event not enabled at PostEvent / slot int dispatch table could not be initialized. /  / bus error /  /  / Couldn't get a needed resource; alert / Operation not permitted)

我不明白我能做些什么来修复它。

我正在观看2011年与推送通知相关的WWDC苹果视频,其中有一张幻灯片显示: enter image description here

它告诉我,如果调用错误委托回调,我应该检查我的权限配置文件的权限。

我做了我可能做的所有事情,但我仍然收到这个错误。我该怎么做才能解决它?

更新1 - 只是为了确认我已启用推送服务列表中的推送通知服务。

enter image description here

更新2 - 确认配置资料中存在推送通知

enter image description here

1 个答案:

答案 0 :(得分:1)

启用目标的推送通知功能。在XCode中,转到目标 - &gt;功能,并确保“推送通知”设置为ON:

Capabilities tab showing Push Notifications set to ON

(感谢@ mateusmaso对此解决方案的评论!)