ios: enable notifications (#713)

This commit is contained in:
JRoberts
2022-05-30 16:15:17 +04:00
committed by GitHub
parent 0bb5774ff1
commit 7e96da95f9
2 changed files with 16 additions and 17 deletions
+10 -11
View File
@@ -21,17 +21,16 @@ class AppDelegate: NSObject, UIApplicationDelegate {
logger.debug("AppDelegate: didRegisterForRemoteNotificationsWithDeviceToken \(token)")
let m = ChatModel.shared
m.deviceToken = token
UserDefaults.standard.set(false, forKey: DEFAULT_USE_NOTIFICATIONS)
// let useNotifications = UserDefaults.standard.bool(forKey: "useNotifications")
// if useNotifications {
// Task {
// do {
// m.tokenStatus = try await apiRegisterToken(token: token)
// } catch {
// logger.error("apiRegisterToken error: \(responseError(error))")
// }
// }
// }
let useNotifications = UserDefaults.standard.bool(forKey: "useNotifications")
if useNotifications {
Task {
do {
m.tokenStatus = try await apiRegisterToken(token: token)
} catch {
logger.error("apiRegisterToken error: \(responseError(error))")
}
}
}
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
@@ -150,12 +150,12 @@ struct SettingsView: View {
} label: {
settingsRow("gauge") { Text("Experimental features") }
}
// if let token = chatModel.deviceToken {
// HStack {
// notificationsIcon()
// notificationsToggle(token)
// }
// }
if let token = chatModel.deviceToken {
HStack {
notificationsIcon()
notificationsToggle(token)
}
}
Text("v\(appVersion ?? "?") (\(appBuild ?? "?"))")
}
}