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 ?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
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()
}
}
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
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