Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions LoopFollow/Remote/LoopAPNS/LoopAPNSService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,6 @@ class LoopAPNSService {
return regex?.firstMatch(in: text, options: [], range: range) != nil
}

/// Provides simple environment guidance for APNS configuration
/// - Returns: String with simple guidance to try opposite setting
private func getEnvironmentGuidance() -> String {
let currentSetting = storage.productionEnvironment.value ? "ON" : "OFF"
let trySetting = storage.productionEnvironment.value ? "OFF" : "ON"

return "Try changing Production Environment from \(currentSetting) to \(trySetting) in your Loop APNS settings."
}

/// Sends an APNS notification
/// - Parameters:
/// - deviceToken: The device token to send to
Expand Down Expand Up @@ -424,8 +415,7 @@ class LoopAPNSService {
LogManager.shared.log(category: .apns, message: "APNS notification sent successfully")
completion(true, nil)
case 400:
let environmentGuidance = self.getEnvironmentGuidance()
let errorMessage = "Bad request. The request was invalid or malformed. \(responseBodyMessage)\n\n\(environmentGuidance)"
let errorMessage = "Bad request. The request was invalid or malformed. \(responseBodyMessage)"
LogManager.shared.log(category: .apns, message: "APNS error 400: \(responseBodyMessage) - Check device token and environment settings")
completion(false, errorMessage)
case 403:
Expand Down
12 changes: 1 addition & 11 deletions LoopFollow/Remote/Settings/RemoteSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,6 @@ struct RemoteSettingsView: View {
.buttonStyle(.borderedProminent)
.frame(maxWidth: .infinity)
.padding(.vertical, 10)

HStack {
Text("Environment")
Spacer()
Toggle("Production", isOn: $viewModel.productionEnvironment)
.toggleStyle(SwitchToggleStyle())
}

Text("Production is used for browser builders and should be switched off for Xcode builders")
.font(.caption)
.foregroundColor(.secondary)
}

if let errorMessage = viewModel.loopAPNSErrorMessage, !errorMessage.isEmpty {
Expand All @@ -258,6 +247,7 @@ struct RemoteSettingsView: View {

Section(header: Text("Debug / Info")) {
Text("Device Token: \(Storage.shared.deviceToken.value)")
Text("APNS Environment: \(Storage.shared.productionEnvironment.value ? "Production" : "Development")")
Text("Bundle ID: \(Storage.shared.bundleId.value)")

if let otpCode = TOTPGenerator.extractOTPFromURL(Storage.shared.loopAPNSQrCodeURL.value) {
Expand Down
9 changes: 0 additions & 9 deletions LoopFollow/Remote/Settings/RemoteSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RemoteSettingsViewModel: ObservableObject {

@Published var loopDeveloperTeamId: String
@Published var loopAPNSQrCodeURL: String
@Published var productionEnvironment: Bool
@Published var isShowingLoopAPNSScanner: Bool = false
@Published var loopAPNSErrorMessage: String?

Expand Down Expand Up @@ -103,8 +102,6 @@ class RemoteSettingsViewModel: ObservableObject {

loopDeveloperTeamId = storage.teamId.value ?? ""
loopAPNSQrCodeURL = storage.loopAPNSQrCodeURL.value
productionEnvironment = storage.productionEnvironment.value

setupBindings()
}

Expand Down Expand Up @@ -188,11 +185,6 @@ class RemoteSettingsViewModel: ObservableObject {
.dropFirst()
.sink { [weak self] in self?.storage.loopAPNSQrCodeURL.value = $0 }
.store(in: &cancellables)

$productionEnvironment
.dropFirst()
.sink { [weak self] in self?.storage.productionEnvironment.value = $0 }
.store(in: &cancellables)
}

func handleLoopAPNSQRCodeScanResult(_ result: Result<String, Error>) {
Expand Down Expand Up @@ -233,7 +225,6 @@ class RemoteSettingsViewModel: ObservableObject {
mealWithFatProtein = storage.mealWithFatProtein.value
loopDeveloperTeamId = storage.teamId.value ?? ""
loopAPNSQrCodeURL = storage.loopAPNSQrCodeURL.value
productionEnvironment = storage.productionEnvironment.value

// Update device-related properties
isTrioDevice = (storage.device.value == "Trio")
Expand Down