HTTP Request every hour

Hello, I'm trying to complete my project for iOS. My application consist in a webview that show pages from my remote server. The application should manage barber bookings. All is working good, but I want that the user must recive a notification when in the current day it has an appointment.


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType([.Alert, .Badge, .Sound]),categories: nil)
        application.registerUserNotificationSettings(settings);
        /
        UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
        return true
    }
   
    func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
        print("Complete");
        notifcationSystem();
        completionHandler(UIBackgroundFetchResult.NewData)
       
    }

Here is how I handled background fetch, but it seems that it don't work always. The function "notificationSystem()" make a web request and read the content. Any suggestions? I want that the app send max 1 request every hour but at least 1 every 2 hours.. How can I handle that?

The application should manage barber bookings. All is working good, but I want that the user must recive a notification when in the current day it has an appointment.

Your best option here is to use remote push notifications to notify the user of their appointment. That is, have the server implement the notification logic rather than the client. Background fetch is useful in some circumstances but it makes no guarantees about when your code will run, and thus you can’t reliably use it to generate notifications like this.

ps I moved your thread to App Frameworks > iOS Multitasking because there’s nothing Swift specific here.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
HTTP Request every hour
 
 
Q