Registering for notification causes error on mac

I am doing something like this:

- (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);
}

And I get the following 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)

I do not understand what I can do to fix this.

I watched an Apple WWDC video in 2011 regarding push notifications, and there was a slide that showed: enter image description here

He tells me that if an error delegate callback is called, I have to check my access profile for rights.

I did my best to make it work, but I still get this error. What can I do to fix this?

UPDATE 1 . Just confirm that I have included push notification services in the list of allowed services.

enter image description here

UPDATE 2 . Confirmation that push notifications are in the provisioning profile

enter image description here

+4
1

Push Notifications . XCode Target → Capabilities , Push Push ON:

Tab

( @mateusmaso !)

+1

Source: https://habr.com/ru/post/1544601/


All Articles