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.4k
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
359
Jun ’21
push or local notification
I want the notifications appear when the app get new post from url and when the user tap on notification that take the user to this post is this work with push or local notification ?
Replies
7
Boosts
0
Views
641
Activity
May ’21
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()     } }
Replies
0
Boosts
0
Views
1.4k
Activity
May ’21
Is NSDataDetector work with data from URLSession ?
Is NSDataDetector work with data from URLSession ? I get data from server as string I want to make emails , phone numbers and links as link not a text
Replies
0
Boosts
0
Views
352
Activity
Jun ’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
Replies
0
Boosts
0
Views
359
Activity
Jun ’21