-
Notifications
You must be signed in to change notification settings - Fork 102
[V5] Use Swift 6 with complete concurrency checking #902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v5
Are you sure you want to change the base?
Changes from 5 commits
5e23ec4
13c55ed
cc74a84
76925c1
fd83af7
9b980e2
4de3548
1365a41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import UIKit | |
/// Handles push notifications in the demo app. | ||
/// When a notification is received, the channel id is extracted from the notification object. | ||
/// The code below shows an example how to use it to navigate directly to the corresponding screen. | ||
class NotificationsHandler: NSObject, ObservableObject, UNUserNotificationCenterDelegate { | ||
@MainActor class NotificationsHandler: NSObject, ObservableObject, UNUserNotificationCenterDelegate { | ||
@Injected(\.chatClient) private var chatClient | ||
|
||
@Published var notificationChannelId: String? | ||
|
@@ -19,7 +19,7 @@ class NotificationsHandler: NSObject, ObservableObject, UNUserNotificationCenter | |
|
||
override private init() {} | ||
|
||
func userNotificationCenter( | ||
nonisolated func userNotificationCenter( | ||
_ center: UNUserNotificationCenter, | ||
didReceive response: UNNotificationResponse, | ||
withCompletionHandler completionHandler: @escaping () -> Void | ||
|
@@ -40,25 +40,28 @@ class NotificationsHandler: NSObject, ObservableObject, UNUserNotificationCenter | |
return | ||
} | ||
|
||
if AppState.shared.userState == .loggedIn { | ||
notificationChannelId = cid.description | ||
} else if let userId = UserDefaults(suiteName: applicationGroupIdentifier)?.string(forKey: currentUserIdRegisteredForPush), | ||
let userCredentials = UserCredentials.builtInUsersByID(id: userId), | ||
let token = try? Token(rawValue: userCredentials.token) { | ||
loginAndNavigateToChannel( | ||
userCredentials: userCredentials, | ||
token: token, | ||
cid: cid | ||
) | ||
Task { @MainActor in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have some consistency in how we run things on the main thread. On the other PR this was done with an abstraction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this piece is not part of the SDK and part of the demo app, I did not want to duplicate here. So demo app uses Task, SDK uses that abstraction (mostly) |
||
if AppState.shared.userState == .loggedIn { | ||
notificationChannelId = cid.description | ||
} else if | ||
let userId = UserDefaults(suiteName: applicationGroupIdentifier)?.string(forKey: currentUserIdRegisteredForPush), | ||
let userCredentials = UserCredentials.builtInUsersByID(id: userId), | ||
let token = try? Token(rawValue: userCredentials.token) { | ||
loginAndNavigateToChannel( | ||
userCredentials: userCredentials, | ||
token: token, | ||
cid: cid | ||
) | ||
} | ||
} | ||
} | ||
|
||
func setupRemoteNotifications() { | ||
UNUserNotificationCenter | ||
.current() | ||
.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in | ||
.requestAuthorization(options: [.alert, .sound, .badge]) { @Sendable granted, _ in | ||
if granted { | ||
DispatchQueue.main.async { | ||
Task { @MainActor in | ||
UIApplication.shared.registerForRemoteNotifications() | ||
} | ||
} | ||
|
@@ -80,11 +83,8 @@ class NotificationsHandler: NSObject, ObservableObject, UNUserNotificationCenter | |
log.debug("Error logging in") | ||
return | ||
} | ||
|
||
DispatchQueue.main.async { | ||
AppState.shared.userState = .loggedIn | ||
self?.notificationChannelId = cid.description | ||
} | ||
AppState.shared.userState = .loggedIn | ||
self?.notificationChannelId = cid.description | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was breaking markdown tests which only happened in this PR because I did a change in
(double space)
MessageView_Test.swift
which then led linter to lint the whole file and apply fixes. Some tests need soft linebreak which is