블로그 이미지
GUCCI

카테고리

전체보기 (111)
여행 (1)
기기 (2)
쇼핑 (0)
게임 (0)
etc. (6)
취업이야기 (0)
업무일지 (5)
리눅스 (38)
웹프로그래밍 (2)
네트워크 (4)
JAVA (17)
Android (0)
IOS (2)
LUA (8)
C/C++ (1)
Objective C (2)
SERVER (2)
그누보드4 (1)
MSSQL (2)
Programming (1)
자바스크립트 (4)
HTML/CSS (1)
LGNAS (0)
Total
Today
Yesterday

IOS8 SDK 알림설정

IOS / 2015. 1. 19. 15:52

앱을 구현하다가 보면 시스템 알림 설정값을 체크해야 하는 경우들이 있다.

일반적으로 iOS8 이전 SDK 에서는 아래와 같은 방법으로 체크를 하였지만,

1
2
3
4
5
6
7
8
if([UIApplication sharedApplication].enabledRemoteNotificationTypes  == UIRemoteNotificationTypeNone) {
    // 시스템 알림 설정이 꺼져있는 경우
}
else {
    // 시스템 알림 설정이 켜져있는 경우.
    // UIRemoteNotificationTypeBadge, UIRemoteNotificationTypeSound, UIRemoteNotificationTypeAlert, UIRemoteNotificationTypeNewsstandContentAvailability
    // 위의 네가지 경우에 만족하는 상태
}


iOS8 SDK 부터는 enabledRemoteNotificationTypes 이 메서드가 Deprecated 되어 사용할 수 없게 되었다.


이 문제를 수정하기 위해서는 iOS8과 그 이하 버전의 분기를 타야 하고, 변경된 메서드를 아래와 같이 적용해 주어야 한다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if ([[UIDevice currentDevice].systemVersion characterAtIndex:0] >= '8') {
    if([UIApplication sharedApplication].currentUserNotificationSettings.types  == UIUserNotificationTypeNone){
    // 시스템 알림 설정이 꺼져있는 경우
    }
    else {
        // 시스템 알림 설정이 켜져있는 경우.
        // UIUserNotificationTypeBadge, UIUserNotificationTypeSound, UIUserNotificationTypeAlert
        // 위의 세가지 경우에 만족하는 상태
    }
}
else {
    if([UIApplication sharedApplication].enabledRemoteNotificationTypes  == UIRemoteNotificationTypeNone){
        // 시스템 알림 설정이 꺼져있는 경우
    }
    else {
        // 시스템 알림 설정이 켜져있는 경우.
        // UIRemoteNotificationTypeBadge, UIRemoteNotificationTypeSound, UIRemoteNotificationTypeAlert, UIRemoteNotificationTypeNewsstandContentAvailability
        // 위의 네가지 경우에 만족하는 상태
    }
}


이 문제는 새로운 버전으로 작업을 하면서 크래쉬같이 눈에 보여서 바로 수정할 수 있는 이슈가 아니라 놓치기 쉬운 문제이니 잘 확인해야 할 것 같다.

'IOS' 카테고리의 다른 글

맥북 구입 점검 사항  (4) 2012.03.22
Posted by GUCCI
, |

최근에 달린 댓글

글 보관함