diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index 227f70c4..5647e05b 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -40,13 +40,17 @@ struct MeshtasticAppleApp: App { } .onOpenURL(perform: { (url) in - print("QR Code URL received from the Camera \(url)") + print("Some sort of URL was received \(url)") channelUrl = url - print("User wants to open URL: \(channelUrl?.absoluteString ?? "No QR Code Link")") + if url.absoluteString.lowercased().contains("https://meshtastic.org/e/#") { saveQR = true + print("User wants to open a Channel Settings URL: \(channelUrl?.absoluteString ?? "No QR Code Link")") + } else { + print("User wants to import a MBTILES offline map file: \(channelUrl?.absoluteString ?? "No Tiles link")") } + //we are expecting a .mbtiles map file that contains raster data //save it to the documents directory, and name it offline_map.mbtiles @@ -60,7 +64,11 @@ struct MeshtasticAppleApp: App { try? fileManager.removeItem(atPath: destination.path) } - try? fileManager.copyItem(at: url, to: destination) + do { + try fileManager.copyItem(at: url, to: destination) + } catch { + print("Copy MB Tile file failed. Error: \(error)") + } if (fileManager.fileExists(atPath: destination.path)) { print("ℹ️ Saved the map file")