How to register for remote notification in Objective C, for iOS 9 and above?

I’ve been using the following code to register for remote notifications using Objective C.

Recently, after building and running the app on a testing device, an iPad mini running iOS 9.3.5, the Debugger Window no longer prints the device token. registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

I am trying to use the device token to send a test notification using Sending Push Notifications Using Command-Line Tools

//REGISTER FOR THE NOTIFICATIONS TYPES

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

{

//-- Set Notification

if ((application respondsToSelector:@selector(isRegisteredForRemoteNotifications)))

{

    // iOS 8 Notifications

    (application registerUserNotificationSettings:(UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil));

    (application registerForRemoteNotifications);

}

else

{

    // iOS < 8 Notifications

    _storyBoard = (UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil);

    ((UIApplication sharedApplication) registerForRemoteNotificationTypes:

     (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert));

}

_storyBoard = (UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil);

((UIApplication sharedApplication) registerForRemoteNotificationTypes:

 (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert));

if (launchOptions != nil)

{

    NSDictionary* dictionary = (launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey);

    if (dictionary != nil)

    {

        NSLog(@"Launched from push notification: %@", dictionary);

        /*(self addMessageFromRemoteNotification:dictionary updateUI:NO);*/

    }

}

return YES;

}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}

didFailToRegisterForRemoteNotificationsWithError is not being called either. What is the correct way to register for push notifications on iOS 9 and above using Objective C?