Last active
August 29, 2015 14:06
-
-
Save skabber/d1ff80669f86c5f5f378 to your computer and use it in GitHub Desktop.
Push registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)updateAlerts | |
{ | |
BOOL alertsMaster = [[NSUserDefaults standardUserDefaults] boolForKey:kAlertsMasterSwitch]; | |
BOOL alertsSounds = [[NSUserDefaults standardUserDefaults] boolForKey:kAlertsSoundSwitch]; | |
BOOL alertsBadge = [[NSUserDefaults standardUserDefaults] boolForKey:kAlertsBadgeSwitch]; | |
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { | |
UIUserNotificationType alert = UIUserNotificationTypeNone; | |
UIUserNotificationType sound = UIUserNotificationTypeNone; | |
UIUserNotificationType badge = UIUserNotificationTypeNone; | |
if (alertsMaster == YES) { | |
alert = UIUserNotificationTypeAlert; | |
} | |
if (alertsSounds == YES) { | |
sound = UIUserNotificationTypeSound; | |
} | |
if (alertsBadge == YES) { | |
badge = UIUserNotificationTypeBadge; | |
} | |
UIUserNotificationType finalTypes = alert|sound|badge; | |
// This should eventually call back to application:didRegisterForRemoteNotificationsWithDeviceToken: | |
[[PushIOManager sharedInstance] registerForRemoteNotificationWithSettings:[UIUserNotificationSettings settingsForTypes:finalTypes categories:nil]]; | |
} else { | |
UIRemoteNotificationType alert = UIRemoteNotificationTypeNone; | |
UIRemoteNotificationType sound = UIRemoteNotificationTypeNone; | |
UIRemoteNotificationType badge = UIRemoteNotificationTypeNone; | |
if (alertsMaster == YES) { | |
alert = UIRemoteNotificationTypeAlert; | |
} | |
if (alertsSounds == YES) { | |
sound = UIRemoteNotificationTypeSound; | |
} | |
if (alertsBadge == YES) { | |
badge = UIRemoteNotificationTypeBadge; | |
} | |
UIRemoteNotificationType finalTypes = alert|sound|badge; | |
// This should eventually call back to application:didRegisterForRemoteNotificationsWithDeviceToken: | |
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:finalTypes]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment