@@ -3,7 +3,6 @@ import platform.Foundation.NSTimer
3
3
import platform.UIKit.UIAlertAction
4
4
import platform.UIKit.UIAlertActionStyleDefault
5
5
import platform.UIKit.UIAlertController
6
- import platform.UIKit.UIAlertControllerStyle
7
6
import platform.UIKit.UIAlertControllerStyleActionSheet
8
7
import platform.UIKit.UIAlertControllerStyleAlert
9
8
import platform.UIKit.UIApplication
@@ -70,23 +69,24 @@ actual fun createNotification(type: NotificationType): Notification = when (type
70
69
options = UNAuthorizationOptionAlert or UNAuthorizationOptionSound
71
70
) { granted, error ->
72
71
if (granted) {
73
- val content = UNMutableNotificationContent ().apply {
74
- setTitle(" Top Notification" )
75
- setBody(message)
76
- setSound(UNNotificationSound .defaultSound())
77
- }
78
-
79
- val trigger = UNTimeIntervalNotificationTrigger .triggerWithTimeInterval(1.0 , false )
72
+ dispatch_async(dispatch_get_main_queue()) {
73
+ val content = UNMutableNotificationContent ().apply {
74
+ setTitle(" Top Notification" )
75
+ setBody(message)
76
+ setSound(UNNotificationSound .defaultSound())
77
+ }
80
78
81
- val request = UNNotificationRequest .requestWithIdentifier(
82
- " topNotification" ,
83
- content,
84
- trigger
85
- )
79
+ val trigger = UNTimeIntervalNotificationTrigger .triggerWithTimeInterval(1.0 , false )
80
+ val request = UNNotificationRequest .requestWithIdentifier(
81
+ " topNotification" ,
82
+ content,
83
+ trigger
84
+ )
86
85
87
- center.addNotificationRequest(request) { error ->
88
- error?.let {
89
- NSLog (" Error scheduling notification: ${it.localizedDescription} " )
86
+ center.addNotificationRequest(request) { error ->
87
+ error?.let {
88
+ NSLog (" Error scheduling notification: ${it.localizedDescription} " )
89
+ }
90
90
}
91
91
}
92
92
} else {
0 commit comments