Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later. #3

Open
juanpasolano opened this issue Jan 13, 2015 · 2 comments

Comments

@juanpasolano
Copy link

I am having this error logged... so i cannot get the token

2015-01-13 10:39:39.452 
apnagent[2482:723049] 
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
@peerax
Copy link

peerax commented Jan 18, 2015

In Swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//ENABLE PUSH NOTIFICATIONS
if (UIApplication.sharedApplication().respondsToSelector(Selector("registerForRemoteNotifications")))
{
var types: UIUserNotificationType = UIUserNotificationType.Badge|UIUserNotificationType.Alert | UIUserNotificationType.Sound
var settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
application.registerUserNotificationSettings( settings )
application.registerForRemoteNotifications()
}
// ios7
else
{
application.registerForRemoteNotificationTypes( UIRemoteNotificationType.Badge |
UIRemoteNotificationType.Sound |
UIRemoteNotificationType.Alert )
}
return true
}

@dominikse
Copy link

Solution:

// Substitute this in didFinishLaunchingWithOptions...
// [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
// (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

// ...with this:
[[UIApplication sharedApplication] respondsToSelector:("registerForRemoteNotifications")];
UIUserNotificationType *types = (UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants