1. uiviewcontroller에 notification 등록
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationEnteredForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
- (void)applicationEnteredForeground:(NSNotification *)notification {
[self updateNotificationSound];
}
2. 설정값 가져오기
- (void)updateNotificationSound
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){
UIUserNotificationType type = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
if (type & UIUserNotificationTypeSound){
_notificationSettingValue.text = @"소리";
} else {
_notificationSettingValue.text = @"무음";
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeSound) {
_notificationSettingValue.text = @"소리";
} else {
_notificationSettingValue.text = @"무음";
}
}
}
3. 상수값의 의미:
UIUserNotificationTypeNone : Allow Notifications on/off
UIUserNotificationTypeBadge : Badge App Icon on/off
UIUserNotificationTypeSound : Sounds on/off
@ How to open application system notification setting view
- (void)launchSystemApplicationNotificationSettingView {
if (&UIApplicationOpenSettingsURLString)
{ //only for ios8
NSURL *appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];}
}
댓글 없음:
댓글 쓰기