فهرست منبع

display alert message for CGM app

display alert message when CGM app is not installed
Pierre L 2 سال پیش
والد
کامیت
cd96bcf3eb
1فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 14 2
      FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift

+ 14 - 2
FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift

@@ -35,7 +35,13 @@ extension CGM {
                         {
                             Section {
                                 Button {
-                                    UIApplication.shared.open(appURL, options: [:], completionHandler: nil) }
+                                    UIApplication.shared.open(appURL, options: [:]) { success in
+                                        if !success {
+                                            self.router.alertMessage
+                                                .send(MessageContent(content: "Unable to open the app", type: .warning))
+                                        }
+                                    }
+                                }
 
                                 label: {
                                     Label(state.displayNameOfApp(), systemImage: "waveform.path.ecg.rectangle").font(.title3) }
@@ -46,7 +52,13 @@ extension CGM {
                         } else if state.cgmCurrent.type == .nightscout && state.url != nil {
                             Section {
                                 Button {
-                                    UIApplication.shared.open(state.url!, options: [:], completionHandler: nil) }
+                                    UIApplication.shared.open(state.url!, options: [:]) { success in
+                                        if !success {
+                                            self.router.alertMessage
+                                                .send(MessageContent(content: "No URL available", type: .warning))
+                                        }
+                                    }
+                                }
                                 label: { Label("Open URL", systemImage: "waveform.path.ecg.rectangle").font(.title3) }
                                     .frame(maxWidth: .infinity, alignment: .center)
                                     .buttonStyle(.bordered)