Skip to content

Commit a1aede5

Browse files
committed
-iOS Notification Bump
1 parent b4f270f commit a1aede5

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

alert-kmp/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ mavenPublishing {
7575
coordinates(
7676
groupId = "io.github.khubaibkhan4",
7777
artifactId = "alert-kmp",
78-
version = "1.0.5"
78+
version = "1.0.6"
7979
)
8080

8181
// Configure POM metadata for the published artifact

alert-kmp/src/iosMain/kotlin/NativeNotify.ios.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import platform.Foundation.NSTimer
33
import platform.UIKit.UIAlertAction
44
import platform.UIKit.UIAlertActionStyleDefault
55
import platform.UIKit.UIAlertController
6-
import platform.UIKit.UIAlertControllerStyle
76
import platform.UIKit.UIAlertControllerStyleActionSheet
87
import platform.UIKit.UIAlertControllerStyleAlert
98
import platform.UIKit.UIApplication
@@ -70,23 +69,24 @@ actual fun createNotification(type: NotificationType): Notification = when (type
7069
options = UNAuthorizationOptionAlert or UNAuthorizationOptionSound
7170
) { granted, error ->
7271
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+
}
8078

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+
)
8685

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+
}
9090
}
9191
}
9292
} else {

0 commit comments

Comments
 (0)