2016-09-26 2 views
4

UNNotificationSettings을 사용하여 iOS 10에서 알림 유형을 얻으려면 어떻게해야합니까? 이전 iOS에서iOS 10에서 UNNotificationSettings를 사용하여 알림 유형을 확인하십시오.

, 나는 이것을 사용합니다 :

UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings]; 

Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES; 
+0

그래서 'UNNotificationSettings' 클래스를 사용하는 방법을 묻는 중입니까? – Droppy

+0

네, 맞아요 ... 열거 형을 사용하는 방법을 찾을 수 없습니다. –

+0

가능한 [UILocalNotification 사용 중지 후 사용자 알림 사용 가능 여부 확인] (https://stackoverflow.com/questions/46664177/check-whe-user-notifications-are-enabled-after-uilocal-notification-deprecati) –

답변

3

을 당신이

UNUserNotificationCenter.currentNotificationCenter().getNotificationSettingsWithCompletionHandler{ (mySettings) in mySettings.alertStyle == .None } 

스위프트 4

를 들어

UNUserNotificationCenter.current().getNotificationSettings{ (mySettings) in mySettings.alertStyle == .none }

목표 - C

에 대해 묻는 희망
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { 
    settings.alertStyle == UNAlertStyleNone 
}] 
+0

수행 방법 객관적으로 - c? –

+1

@MehulChuahan Objective-C 코드로 답변을 업데이트했습니다. –

관련 문제