Get the Push-Notification list on iOS8

10,829

Its very simple try this in Xcode6:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //-- Set Notification
        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)];
        }

     //--- your custom code
     return YES;
}
Share:
10,829
Massimo Piazza
Author by

Massimo Piazza

Updated on July 28, 2022

Comments

  • Massimo Piazza
    Massimo Piazza almost 2 years

    Is it possible to get the text of all the received push notifications on iOS 8?

    Has anyone found something on the documentation provided by Apple?

    I know that the notification list can be obtained using a bluetooth device, but I'd like to get it locally.

  • Rajesh Loganathan
    Rajesh Loganathan about 10 years
    Its correct only.. You can use this in Xcode6 Beta, Not Xcode5.1 or later.
  • Ramon
    Ramon about 10 years
    Nope, not true. You're registering for push notifications. The above functions generate a popup that the user has to accept and return a 'push token'. This has nothing to do with any notification list. The push token can be used for pushing those notifications that you'd like to read. (Like the bluetooth watch, for example)
  • Marckaraujo
    Marckaraujo almost 10 years
    @SVMRAJESH, it don't work using Xcode6 SDK with iOS 7.x simulator or any device with iOS 7.x
  • Nishan29
    Nishan29 almost 10 years
    @SVMRAJESH , I have used the same sample code for Push Notification. I'm not receiving any Push Notifications in iOS 8.0 . Please help me out wit this issue.
  • Nishan29
    Nishan29 almost 10 years
    @SVMRAJESH, I'm using the below code for the same to get the Push Token, - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)de‌​viceToken { NSLog(@"My token is: %@", deviceToken); PUSH TOKEN = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""] ;
  • 0x6A75616E
    0x6A75616E over 9 years
    this does not answer the question at all
  • jsetting32
    jsetting32 over 9 years
    Xcode is still throwing errors how do I remove them? do i use a #if-else condition? Sorry... this is probably a simple fix
  • jsetting32
    jsetting32 over 9 years
    6 but I solved the issue. I had to make a preprocessor condition I guess. Idk if this is the way to do it but the errors are gone and the app now works with push notifications in ios8
  • tesmojones
    tesmojones over 9 years
    @SVMRAJESH, it don't work using Xcode6 SDK 8.1 with iOS 7.x device.
  • jsetting32
    jsetting32 over 9 years
    restart your phone then set the time to 2 days in the future... then restart set your phone back to normal time. This is what did it for me