Apple PUshNotification Apply Code

AppDelegate.m

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

    {

        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [[UIApplication sharedApplication] registerForRemoteNotifications];

    }

    else

    {

        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:

         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

    }

– (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error

{

NSLog(@”%@”,[error description]);

}

– (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

{

strDeviceToken=[[[deviceToken description]

                     stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”<>”]]

stringByReplacingOccurrencesOfString:@” ” withString:@””];

    NSLog(@”%@”,strDeviceToken);

     NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

      [prefs setObject:strDeviceToken forKey:token1];

[prefs synchronize];

}