@@ -48,6 +48,10 @@ func getFlutterError(_ error: Error) -> FlutterError {
4848 case " setNotificationCategories " :
4949 setNotificationCategories ( arguments: call. arguments!)
5050 result ( nil )
51+ case " getNotificationSettings " :
52+ getNotificationSettings ( ) { ( value) in
53+ result ( value)
54+ }
5155 default :
5256 assertionFailure ( call. method)
5357 result ( FlutterMethodNotImplemented)
@@ -105,6 +109,23 @@ func getFlutterError(_ error: Error) -> FlutterError {
105109 }
106110 }
107111
112+ func getNotificationSettings( completion: @escaping ( ( [ String : Bool ] ) -> Void ) ) {
113+ let center = UNUserNotificationCenter . current ( )
114+ let application = UIApplication . shared
115+
116+ assert ( center. delegate != nil )
117+
118+ center. getNotificationSettings { ( settings) in
119+ let map = [
120+ " sound " : settings. soundSetting == . enabled,
121+ " badge " : settings. badgeSetting == . enabled,
122+ " alert " : settings. alertSetting == . enabled,
123+ " carPlay " : settings. carPlaySetting == . enabled,
124+ ]
125+ completion ( map)
126+ }
127+ }
128+
108129 func requestNotificationPermissions( _ call: FlutterMethodCall , result: @escaping FlutterResult ) {
109130 let center = UNUserNotificationCenter . current ( )
110131 let application = UIApplication . shared
@@ -130,14 +151,6 @@ func getFlutterError(_ error: Error) -> FlutterError {
130151 if readBool ( " carPlay " ) {
131152 options. append ( . carPlay)
132153 }
133-
134- var provisionalRequested = false
135- if #available( iOS 12 . 0 , * ) {
136- if readBool ( " provisional " ) {
137- options. append ( . provisional)
138- provisionalRequested = true
139- }
140- }
141154
142155
143156 let optionsUnion = UNAuthorizationOptions ( options)
@@ -148,16 +161,9 @@ func getFlutterError(_ error: Error) -> FlutterError {
148161 return
149162 }
150163
151- center. getNotificationSettings { ( settings) in
152- let map = [
153- " sound " : settings. soundSetting == . enabled,
154- " badge " : settings. badgeSetting == . enabled,
155- " alert " : settings. alertSetting == . enabled,
156- " carPlay " : settings. carPlaySetting == . enabled,
157- " provisional " : granted && provisionalRequested
158- ]
159-
160- self . channel. invokeMethod ( " onIosSettingsRegistered " , arguments: map)
164+ self . getNotificationSettings ( ) { ( value) in
165+ self . channel. invokeMethod ( " onIosSettingsRegistered " , arguments: value)
166+
161167 }
162168
163169 result ( granted)
0 commit comments