Post

Replies

Boosts

Views

Activity

Call API when app is in background
I use SwiftUi I want to call API when app is in background and send notifications to users This is my code to call API. I found this way from Apple Dec - https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/updating_your_app_with_background_app_refresh#2928664 for Background fetch But this for UIkit }         .onAppear(perform: loadData)     }     func loadData() {         guard let url = URL(string: "My API") else {             print("Invalid URL")             return         }         let request = URLRequest(url: url)         URLSession.shared.dataTask(with: request) { data, response, error in             if let data = data {                 if let decodedResponse = try? JSONDecoder().decode([Result].self, from: data) {                     DispatchQueue.main.async {                         self.results = decodedResponse                     }                     return                 }             }             print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")")         }.resume()     } }
0
0
1.3k
May ’21
detect email and phone numbers
I get JSON data from the server the data look like this "title": { "rendered": "Popular Quotes" }, "Content":{ "rendered" : " Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. Test@test.com +123-234-567" I receive new data everyday that have email address and phone numbers I want to detect email address and phon numbers to be tap able how can I do that in swiftui
0
0
351
Jun ’21