Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 1.66 KB  |  hits: 76  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Registering for Push Notification
  2. [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
  3.  
  4. application:didRegisterForRemoteNotificationsWithDeviceToken:
  5. application:didFailToRegisterForRemoteNotificationsWithError:
  6.        
  7. UIRemoteNotificationType notificationTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
  8.        
  9. if (notificationTypes == UIRemoteNotificationTypeNone) {
  10.     // Do what ever you need to here when notifications are disabled
  11. } else if (notificationTypes == UIRemoteNotificationTypeBadge) {
  12.     // Badge only
  13. } else if (notificationTypes == UIRemoteNotificationTypeAlert) {
  14.     // Alert only
  15. } else if (notificationTypes == UIRemoteNotificationTypeSound) {
  16.     // Sound only
  17. } else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)) {
  18.     // Badge & Alert
  19. } else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)) {
  20.     // Badge & Sound        
  21. } else if (notificationTypes == (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
  22.     // Alert & Sound
  23. } else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
  24.     // Badge, Alert & Sound    
  25. }
  26.        
  27. if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != 0) {
  28.     //at least one bit is set
  29. }
  30.        
  31. UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
  32. if (enabledTypes & UIRemoteNotificationTypeBadge) {
  33.     //UIRemoteNotificationTypeBadge is set in the bitmask
  34. }