I have implemented OneSignal push notifications in my iOS Swift app. I am sending a push notification from my server and I want the app, on receiving this, to perform an HTTP Get request to get data from my server. I want to check this data for new data and only show the notification to the user if any data is available. If this is not possible, then how can I run a background task every ten minutes even when the app is swiped away? Here is my code right now
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
Alamofire.request("my-url", method: .get, parameters: my-parameters).reponseJSON {
// Check for any new data
if isNewData {
// Send user a local notification
} else {
return
}
}
}