Skip to content

Instantly share code, notes, and snippets.

@celian-m
Last active January 19, 2016 13:37
Show Gist options
  • Save celian-m/e50abdc24d6bbf5636c7 to your computer and use it in GitHub Desktop.
Save celian-m/e50abdc24d6bbf5636c7 to your computer and use it in GitHub Desktop.
Registering for remote notificatiosn

#Register for remote notifications in Objective-C

    if ([application
         respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:
        UIUserNotificationTypeAlert | 
        UIUserNotificationTypeBadge | 
        UIUserNotificationTypeSound categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
        
    } else {
        
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
        
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment