Files
damus/damus/Views/Settings/DeveloperSettingsView.swift
Daniel D’Aquino 3902fe7b30 Enable push notifications feature for everyone and set notification mode to push
This commit hardcodes the push notification feature flag to true, in
preparation for purple testflight release.

It also changes the notification mode setting string, to ensure that we
won't have issues with people being stuck with local notification mode.

Testing
-------

Steps:
1. Run app
2. Ensure push notification flag is gone from developer Settings
3. Ensure notification mode is set to push, and that the push option is available
4. Ensure push notification settings appear as "synced successfully"

Conditions:
- iPhone 13 mini, iOS 17.6.1, on a device that was already under testing
- iPad simulator, iOS 17.5, brand new account

Changelog-Added: Push notification support
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-09-06 14:29:19 -07:00

104 lines
5.9 KiB
Swift

//
// DeveloperSettingsView.swift
// damus
//
// Created by Bryan Montz on 7/6/23.
//
import Foundation
import SwiftUI
struct DeveloperSettingsView: View {
@ObservedObject var settings: UserSettingsStore
var body: some View {
Form {
Section(footer: Text("Developer Mode enables features and options that may help developers diagnose issues and improve this app. Most users will not need Developer Mode.", comment: "Section header for Developer Settings view")) {
Toggle(NSLocalizedString("Developer Mode", comment: "Setting to enable developer mode"), isOn: $settings.developer_mode)
.toggleStyle(.switch)
if settings.developer_mode {
Toggle(NSLocalizedString("Always show onboarding", comment: "Developer mode setting to always show onboarding suggestions."), isOn: $settings.always_show_onboarding_suggestions)
Picker(NSLocalizedString("Push notification environment", comment: "Prompt selection of the Push notification environment (Developer feature to switch between real/production mode to test modes)."),
selection: Binding(
get: { () -> PushNotificationClient.Environment in
switch settings.push_notification_environment {
case .local_test(_):
return .local_test(host: nil) // Avoid errors related to a value which is not a valid picker option
default:
return settings.push_notification_environment
}
},
set: { new_value in
settings.push_notification_environment = new_value
}
)
) {
ForEach(PushNotificationClient.Environment.allCases, id: \.self) { push_notification_environment in
Text(push_notification_environment.text_description())
.tag(push_notification_environment.to_string())
}
}
if case .local_test(_) = settings.push_notification_environment {
TextField(
NSLocalizedString("URL", comment: "Custom URL host for Damus push notification testing"),
text: Binding.init(
get: {
return settings.push_notification_environment.custom_host() ?? ""
}, set: { new_host_value in
settings.push_notification_environment = .local_test(host: new_host_value)
}
)
)
.disableAutocorrection(true)
.autocapitalization(UITextAutocapitalizationType.none)
}
Toggle(NSLocalizedString("Enable experimental Purple API support", comment: "Developer mode setting to enable experimental Purple API support."), isOn: $settings.enable_experimental_purple_api)
.toggleStyle(.switch)
Picker(NSLocalizedString("Damus Purple environment", comment: "Prompt selection of the Damus purple environment (Developer feature to switch between real/production mode to test modes)."),
selection: Binding(
get: { () -> DamusPurpleEnvironment in
switch settings.purple_enviroment {
case .local_test(_):
return .local_test(host: nil) // Avoid errors related to a value which is not a valid picker option
default:
return settings.purple_enviroment
}
},
set: { new_value in
settings.purple_enviroment = new_value
}
)
) {
ForEach(DamusPurpleEnvironment.allCases, id: \.self) { purple_environment in
Text(purple_environment.text_description())
.tag(purple_environment.to_string())
}
}
if case .local_test(_) = settings.purple_enviroment {
TextField(
NSLocalizedString("URL", comment: "Custom URL host for Damus Purple testing"),
text: Binding.init(
get: {
return settings.purple_enviroment.custom_host() ?? ""
}, set: { new_host_value in
settings.purple_enviroment = .local_test(host: new_host_value)
}
)
)
.disableAutocorrection(true)
.autocapitalization(UITextAutocapitalizationType.none)
}
Toggle(NSLocalizedString("Enable experimental Purple In-app purchase support", comment: "Developer mode setting to enable experimental Purple In-app purchase support."), isOn: $settings.enable_experimental_purple_iap_support)
.toggleStyle(.switch)
}
}
}
.navigationTitle(NSLocalizedString("Developer", comment: "Navigation title for developer settings"))
}
}