
Untitled
By: a guest on
Jun 9th, 2012 | syntax:
None | size: 1.66 KB | hits: 76 | expires: Never
Registering for Push Notification
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
application:didRegisterForRemoteNotificationsWithDeviceToken:
application:didFailToRegisterForRemoteNotificationsWithError:
UIRemoteNotificationType notificationTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (notificationTypes == UIRemoteNotificationTypeNone) {
// Do what ever you need to here when notifications are disabled
} else if (notificationTypes == UIRemoteNotificationTypeBadge) {
// Badge only
} else if (notificationTypes == UIRemoteNotificationTypeAlert) {
// Alert only
} else if (notificationTypes == UIRemoteNotificationTypeSound) {
// Sound only
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)) {
// Badge & Alert
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)) {
// Badge & Sound
} else if (notificationTypes == (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
// Alert & Sound
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
// Badge, Alert & Sound
}
if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != 0) {
//at least one bit is set
}
UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (enabledTypes & UIRemoteNotificationTypeBadge) {
//UIRemoteNotificationTypeBadge is set in the bitmask
}