gpt4 book ai didi

objective-c - 注册通知导致 mac 上出错

转载 作者:搜寻专家 更新时间:2023-10-30 19:47:35 25 4
gpt4 key购买 nike

我正在做这样的事情:

- (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 apple 视频,其中有一张幻灯片显示: enter image description here

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

我已尽我所能使事情正常进行,但我仍然收到此错误。我该怎么做才能修复它?

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

enter image description here

更新 2 - 确认推送通知存在于配置文件中

enter image description here

最佳答案

为您的目标开启推送通知功能。在 XCode 中,转到目标 -> 功能,并确保“推送通知”设置为开启:

Capabilities tab showing Push Notifications set to ON

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

关于objective-c - 注册通知导致 mac 上出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24223711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com