2016-09-26 57 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

はい、そうです...私はenumを使う方法を見つけることができません。 –

+0

[UILocalNotification廃止後にユーザー通知が有効になっているかどうかを確認する](https://stackoverflow.com/questions/46664177/check-whether-user-notifications-are-enabled-after-uilocalnotification-deprecati) –

答えて

3

を私はあなたがこの

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

スウィフト4

については

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

のObjective-C

について尋ねている願っています
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { 
    settings.alertStyle == UNAlertStyleNone 
}] 
+0

操作方法それは客観的に - c? –

+1

@MehulChuahan Objective-Cコードで更新された解答。 –

関連する問題