diff --git a/xdrip/Managers/NightScout/NightScoutUploadManager.swift b/xdrip/Managers/NightScout/NightScoutUploadManager.swift
index 5e135cae..8713310c 100644
--- a/xdrip/Managers/NightScout/NightScoutUploadManager.swift
+++ b/xdrip/Managers/NightScout/NightScoutUploadManager.swift
@@ -344,7 +344,7 @@ public class NightScoutUploadManager: NSObject {
if (keyValueObserverTimeKeeper.verifyKey(forKey: keyPathEnum.rawValue, withMinimumDelayMilliSeconds: 200)) {
// if master is set, siteURL exists and either API_SECRET or a token is entered, then test credentials
- if UserDefaults.standard.nightScoutUrl != "" && UserDefaults.standard.isMaster && (UserDefaults.standard.nightScoutAPIKey != "" || UserDefaults.standard.nightscoutToken != "") {
+ if UserDefaults.standard.nightScoutUrl != nil && UserDefaults.standard.isMaster && (UserDefaults.standard.nightScoutAPIKey != nil || UserDefaults.standard.nightscoutToken != nil) {
testNightScoutCredentials({ (success, error) in
DispatchQueue.main.async {
@@ -368,7 +368,7 @@ public class NightScoutUploadManager: NSObject {
if (keyValueObserverTimeKeeper.verifyKey(forKey: keyPathEnum.rawValue, withMinimumDelayMilliSeconds: 200)) {
// if master is set, siteURL exists and either API_SECRET or a token is entered, then test credentials
- if UserDefaults.standard.nightScoutUrl != "" && UserDefaults.standard.isMaster && (UserDefaults.standard.nightScoutAPIKey != "" || UserDefaults.standard.nightscoutToken != "") {
+ if UserDefaults.standard.nightScoutUrl != nil && UserDefaults.standard.isMaster && (UserDefaults.standard.nightScoutAPIKey != nil || UserDefaults.standard.nightscoutToken != nil) {
testNightScoutCredentials({ (success, error) in
DispatchQueue.main.async {
@@ -407,8 +407,6 @@ public class NightScoutUploadManager: NSObject {
/// upload battery level to nightscout
/// - parameters:
- /// - siteURL : nightscout site url
- /// - apiKey : nightscout api key
/// - transmitterBatteryInfosensor: setransmitterBatteryInfosensornsor to upload
private func uploadTransmitterBatteryInfoToNightScout(transmitterBatteryInfo: TransmitterBatteryInfo) {
@@ -1195,7 +1193,12 @@ public class NightScoutUploadManager: NSObject {
private func testNightScoutCredentials(_ completion: @escaping (_ success: Bool, _ error: Error?) -> Void) {
- if let nightSccoutUrl = UserDefaults.standard.nightScoutUrl, let url = URL(string: nightSccoutUrl), var uRLComponents = URLComponents(url: url.appendingPathComponent(nightScoutAuthTestPath), resolvingAgainstBaseURL: false) {
+ // don't run the test if one of the authentication methods is missing. This can happen because the user has input the URL but hasn't added auth yet.
+ if UserDefaults.standard.nightScoutAPIKey == nil && UserDefaults.standard.nightscoutToken == nil {
+ return
+ }
+
+ if let nightscoutURL = UserDefaults.standard.nightScoutUrl, let url = URL(string: nightscoutURL), var uRLComponents = URLComponents(url: url.appendingPathComponent(nightScoutAuthTestPath), resolvingAgainstBaseURL: false) {
if UserDefaults.standard.nightScoutPort != 0 {
uRLComponents.port = UserDefaults.standard.nightScoutPort
diff --git a/xdrip/Storyboards/Base.lproj/Main.storyboard b/xdrip/Storyboards/Base.lproj/Main.storyboard
index ccaa64c0..92f3b474 100644
--- a/xdrip/Storyboards/Base.lproj/Main.storyboard
+++ b/xdrip/Storyboards/Base.lproj/Main.storyboard
@@ -295,7 +295,6 @@
-
@@ -309,12 +308,17 @@
-
+
+
+
+
+
+
@@ -717,6 +721,7 @@
+
@@ -738,6 +743,7 @@
+
@@ -833,7 +839,7 @@
-
+
@@ -915,7 +921,7 @@
-
+
@@ -997,7 +1003,7 @@
-
+
@@ -1967,7 +1973,7 @@
-
+