ios: disable notifications if not migrated (#766)
* ios: disable notifications if not migrated * refactor, update text
This commit is contained in:
committed by
GitHub
parent
e68cc23828
commit
a8a0f2db03
@@ -81,7 +81,7 @@ struct SimpleXApp: App {
|
|||||||
// dbContainerGroupDefault.set(.documents)
|
// dbContainerGroupDefault.set(.documents)
|
||||||
// v3DBMigrationDefault.set(.offer)
|
// v3DBMigrationDefault.set(.offer)
|
||||||
// to create database in app documents folder also uncomment:
|
// to create database in app documents folder also uncomment:
|
||||||
// let legacyDatabase = true
|
// let legacyDatabase = true
|
||||||
let legacyDatabase = hasLegacyDatabase()
|
let legacyDatabase = hasLegacyDatabase()
|
||||||
if legacyDatabase, case .documents = dbContainerGroupDefault.get() {
|
if legacyDatabase, case .documents = dbContainerGroupDefault.get() {
|
||||||
dbContainerGroupDefault.set(.documents)
|
dbContainerGroupDefault.set(.documents)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ struct NotificationsView: View {
|
|||||||
@EnvironmentObject var m: ChatModel
|
@EnvironmentObject var m: ChatModel
|
||||||
@State private var notificationMode: NotificationsMode?
|
@State private var notificationMode: NotificationsMode?
|
||||||
@State private var showAlert: NotificationAlert?
|
@State private var showAlert: NotificationAlert?
|
||||||
|
@State private var legacyDatabase = dbContainerGroupDefault.get() == .documents
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
@@ -69,8 +70,15 @@ struct NotificationsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} header: {
|
} header: {
|
||||||
Text("Message notifications")
|
Text("Push notifications")
|
||||||
|
} footer: {
|
||||||
|
if legacyDatabase {
|
||||||
|
Text("Please restart the app and migrate the database to enable push notifications.")
|
||||||
|
.font(.callout)
|
||||||
|
.padding(.top, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
.disabled(legacyDatabase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func receiveNtfMessages(_ request: UNNotificationRequest, _ contentHandler: @escaping (UNNotificationContent) -> Void) {
|
func receiveNtfMessages(_ request: UNNotificationRequest, _ contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||||
|
if case .documents = dbContainerGroupDefault.get() {
|
||||||
|
contentHandler(request.content)
|
||||||
|
return
|
||||||
|
}
|
||||||
let userInfo = request.content.userInfo
|
let userInfo = request.content.userInfo
|
||||||
if let ntfData = userInfo["notificationData"] as? [AnyHashable : Any],
|
if let ntfData = userInfo["notificationData"] as? [AnyHashable : Any],
|
||||||
let nonce = ntfData["nonce"] as? String,
|
let nonce = ntfData["nonce"] as? String,
|
||||||
|
|||||||
Reference in New Issue
Block a user